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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikuser22
Creator II
Creator II

Joining two tables with same fields

Hi

I am struck with a problem where I have two tables and want to extract the data and final result in one table.

 

Tabl1:

Load 

EmpNo,

EmpName,

City,

Country,

Address

from abc.qvd;

Tabl2:

Load 

EmpNo

EmpCity,

EmpAddr,

EmpCountry,

EmpSalary

from xyz.qvd;

 

I need to do something like, For each employee number , I want to produce the address, city and country. If the details are not available I have to pick the address, city and country from table2. 

The final table should be,

EmpNo, EmpName, City,Country,Address, EmpSalary

 

Thanks.

Please do help. 

1 Solution

Accepted Solutions
Taoufiq_Zarra

@qlikuser22  you can for example use :

Tabl1:

Load 

EmpNo,

EmpName,

City,

Country,

Address

from abc.qvd;

left join

Load 

EmpNo

EmpCity,

EmpAddr,

EmpCountry,

EmpSalary

from xyz.qvd;

Final:
noconcatenate

load EmpNo, EmpName, if(len(trim(City))=0,EmpCity,City) as  City,if(len(trim(Country))=0,EmpCountry,Country) as  Country , if(len(trim(Address))=0,EmpAddr,Address) as Address,  EmpSalary resident Tabl1;

drop table Tabl1;
Regards,
Taoufiq ZARRA

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

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

View solution in original post

3 Replies
Taoufiq_Zarra

@qlikuser22  you can for example use :

Tabl1:

Load 

EmpNo,

EmpName,

City,

Country,

Address

from abc.qvd;

left join

Load 

EmpNo

EmpCity,

EmpAddr,

EmpCountry,

EmpSalary

from xyz.qvd;

Final:
noconcatenate

load EmpNo, EmpName, if(len(trim(City))=0,EmpCity,City) as  City,if(len(trim(Country))=0,EmpCountry,Country) as  Country , if(len(trim(Address))=0,EmpAddr,Address) as Address,  EmpSalary resident Tabl1;

drop table Tabl1;
Regards,
Taoufiq ZARRA

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

(you can mark up to 3 "solutions") 😉
qlikuser22
Creator II
Creator II
Author

@Taoufiq_Zarra  It worked perfectly. I was struggling a lot in this. There is so much to learn. Thanks a lot 🙂 

qlikuser22
Creator II
Creator II
Author

HI @Taoufiq_Zarra 

I made some modifications to the above code. Now the addr,city,country is available in the database but it is not reflecting in qliksense.'

The changes I perferomed is,

I wrote a mapping load  and tried to use apply map to get the details.  I can see the data is available in the raw file but in qliksense I am getting NULL values. 

MapTable:
Mapping Load 
EmpNo,City
from abc.xlsx;

Tabl1:

Load 

EmpNo,

EmpName,

Applymap('MapTable',EmpNo,'NA') as City,

Country,

Address

from abc.qvd;

left join

Load 

EmpNo

EmpCity,

EmpAddr,

EmpCountry,

EmpSalary

from xyz.qvd;

Final:
noconcatenate

load EmpNo, EmpName, if(len(trim(City))=0,EmpCity,City) as  City,if(len(trim(Country))=0,EmpCountry,Country) as  Country , if(len(trim(Address))=0,EmpAddr,Address) as Address,  EmpSalary resident Tabl1;

drop table Tabl1;

Thanks in advance!!