Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am facing a challenge while using for loop with a left Join
Requirement- I have two tables one having list of Area Name and employee IDs, the other having Employee IDs to manager IDs mapping
Table 1 | |
Area Name | Employee ID |
A | 123456 |
B | 1234567 |
C | 234567 |
D | 345678 |
Table 2 | |
ID | Manager ID |
123456 | 1234 |
1234567 | 1234 |
234567 | 2345 |
345678 | 3456 |
3456 | 34 |
1234 | 12 |
2345 | 23 |
Task-
I need to Left Join Table 2 into table 1, so that the resultant table looks like below
Table 1 | ||
Area Name | ID | Manager ID |
A | 123456 | 1234 |
B | 1234567 | 1234 |
C | 234567 | 2345 |
D | 345678 | 3456 |
Other Steps-
1. Make a temp table of Table 1
2. Drop field Terr ID from Temp Table
3. Rename Field Terr Manager ID as Terr ID
4. Concatenate Temp table with Table 1
Challenge-
I need to repeat the process until there is no Manager ID mapped to an employee id. For example 12 in my case
It looks like you are trying to load hierarchy data. If so then check out the link and the script prefixes Hierarchy and HierarchyBelongsTo , it might help you achieve what you want and also reduce the complexity in your script.
Good luck
Vegar
Hi Vegar,
Thanks for the reply !!
My requirement is a little different as i want to bring more fields in Table 1 after the left join from another table x.
Will it be possible using do ...loop ?
I am running off what Vegar posted, the following link has some further info on things related to where he was headed I think that may be of help:
https://community.qlik.com/t5/Qlik-Design-Blog/Unbalanced-n-level-hierarchies/ba-p/1474325
I am not certain this is what you need though, so here is the base link for the Design Blog area you can use to search yourself to see if you can find something to help further there:
https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog
Regards,
Brett