Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Left join a table twice by specific field

Hi all,

I have a requirement that need to join two tables twice by different field. Below is the scenario

Table A

Field 1Field 2Field 3
1F21
2F32
3F23
4F34

Table B

Field 4Field 5Field 6
AF21
BF22F32
CF23
DF34

Table A Field 3 left join Table B field 6

Result of first Join

Field 1Field 2Field 3Field 4Field 5
1F21
2F32BF22
3F23
4F34D

Table A Field 2 left join Table B field 5

Result of second Join

Field 1Field 2Field 3Field 4Field 5Field 6
1F21A
2F32BF22
3F23C
4F34D

How can i do the above joining in loading script?

Best Regards,

Louis

5 Replies
vinieme12
Champion III
Champion III

Use Left join once and use Applymap() the second time

Example

Load

temp:

Field1,Field2,Field3

From Table1Src;

Left Join

Field4,Field5,Field6 as Field3

From Table2Src

Map_Field4:

Mapping Load Distinct Field5,

Field4

From Table2Src;

NOCONCATENATE

FACT:

LOAD

Field1,

Field2,

Field3,

if(isnull(Field4),Applymap('Map_Field4',Field5),Field4) as Field4

Field5

RESIDENT temp;

Drop Table temp;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

give this a read

Don't join - use Applymap instead

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
maxgro
MVP
MVP

1.png

A:

LOAD [Field 1],

     if(len(trim([Field 2]))=0, null(), [Field 2]) as [Field 2],

     if(len(trim([Field 3]))=0, null(), [Field 3]) as [Field 3]

FROM [https://community.qlik.com/thread/248886] (html, codepage is 1252, embedded labels, table is @1);

Join (A)

LOAD [Field 4],

     if(len(trim([Field 5]))=0, null(), [Field 5]) as [Field 5],

     if(len(trim([Field 6]))=0, null(), [Field 6]) as [Field 6]

FROM [https://community.qlik.com/thread/248886] (html, codepage is 1252, embedded labels, table is @2);

B:

NoConcatenate LOAD  *

Resident A

Where [Field 2]=[Field 5] or [Field 3]=[Field 6];

DROP Table A;

Anonymous
Not applicable
Author

Hi Massimo,

Can you provide the .qvw for reference?

Best Regards,

Louis

maxgro
MVP
MVP

yes but I've already posted all the script