Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.
cancel
Showing results for 
Search instead for 
Did you mean: 
DoubleG
Contributor
Contributor

Left join first row

Hello everyone,

How to left join values from one table to another only first row in Data Load?

Example:

Table A:

Date             Product Owner              Product                  Color

20220101  John                 Product1                        Green

20220101  John                  Product1                       Yellow

20220101  Jessica              Product1                         Black

20220101  Jessica              Product1                         Blue

20220101  Steven             Product1                        Grey

20220101  Steven             Product1                        Red

 

Tabla B:

Date             Product Owner              Product                  Sales Target

20220101  John                 Product1                        2000

20220101  Jessica                 Product1                        3000

20220101  Steven             Product1                       6000

 

Result Table:

Date             Product Owner              Product                  Color    Sales Target

20220101  John                 Product1                        Green    2000

20220101  John                  Product1                       Yellow

20220101  Jessica              Product1                         Black  3000

20220101  Jessica              Product1                         Blue

20220101  Steven             Product1                        Grey    6000

20220101  Steven             Product1                        Red   

 

 

Need ignore other fields which aren't at table B and match only first row.

Thanks.

 

 

 

 

 

Labels (1)
1 Reply
Taoufiq_Zarra

@DoubleG  Maye be like :

TableA:

load *,rowno() as Flag  inline [
Date,Product Owner,Product,Color

20220101,John,Product1,Green

20220101,John,Product1,Yellow

20220101,Jessica,Product1,Black

20220101,Jessica,Product1,Blue

20220101,Steven,Product1,Grey

20220101,Steven,Product1,Red

];

left join

load * inline [
Date,Product Owner,Product,Sales Target

20220101,John,Product1,2000

20220101,Jessica,Product1,3000

20220101,Steven,Product1,6000

];

output:
load Date,[Product Owner],Product,if(Date&[Product Owner]&Product=peek(Date)&peek([Product Owner])&peek(Product),'',[Sales Target]) as [Sales Target] resident TableA order by Flag;

drop table TableA;

 

output:

Taoufiq_Zarra_0-1645102958351.png

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉