Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rsdhavle
Creator II
Creator II

Rows getting duplicated when conditional columns are added

I am joining two tables on one key field. I have to calculate few conditional columns based on values from one column of a second table.

When I add these conditional columns along with columns present in first table inside straight table rows with null entries get added in the table. How to handle this?

1 Solution

Accepted Solutions
PrashantSangle

Try like

Load * from Table1;

Left Join

Load  Client,Role,EmpName as SalesHead from Table2

where RoleName='SalesHead';

Left Join

Load  Client,Role,EmpName as RegionHead from Table2

where RoleName='RegionHead';

Left Join

Load  Client,Role,EmpName as SalesManager from Table2

where RoleName='SalesManager';

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

8 Replies
YoussefBelloum
Champion
Champion

Hi,

I think we need more details here. would you be able to share some data and the script ? or to attach some screen shots ?

rsdhavle
Creator II
Creator II
Author

Table1

Client Unique RecordsClientTypeCountryRegion
AX
BY
Cz

Table 2

ClientRoleRoleNameEmpName
A1SalesHeadABCD
A2RegionHeadXYZ
B3SalesManagerUVW

Now by joining Table 2 with 1 on key client I need to form additional columns with names as Sales Head , Region Head which should display employee names from table 2 as their values so resulting table will be like below.

Currently I am doing left join for each role id with table 1 as in doing self join but would like to know if there is better solution to handle this scenario like applymap or anything else..

ClientUniqueRecondclienttypeSalesHeadRegionHead
AXABCDXYZ
rsdhavle
Creator II
Creator II
Author

gwassenaar‌ can you suggest a good solution for this?

PrashantSangle

Try like

Load * from Table1;

Left Join

Load  Client,Role,EmpName as SalesHead from Table2

where RoleName='SalesHead';

Left Join

Load  Client,Role,EmpName as RegionHead from Table2

where RoleName='RegionHead';

Left Join

Load  Client,Role,EmpName as SalesManager from Table2

where RoleName='SalesManager';

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
YoussefBelloum
Champion
Champion

What is the calculation rule for the new field "region head" here ?

for Client A, it could be XYZ or ABCD, right ?

PrashantSangle

I think it is based on RoleName

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
YoussefBelloum
Champion
Champion

Yes, it is the only logical explanation..

rsdhavle
Creator II
Creator II
Author

Yes I have implemented it like this way currently. I would like to know if we use some function like ApplyMap and create multiple Mapping loads will that be a better solution performance wise or it will not make much difference?