Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
siddharthsoam
Partner - Creator II
Partner - Creator II

Using For Loop

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
A123456
B1234567
C234567
D345678

 

Table 2
 ID Manager ID
1234561234
12345671234
2345672345
3456783456
345634
123412
234523

 

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
A1234561234
B12345671234
C2345672345
D3456783456

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

 

 

3 Replies
Vegar
MVP
MVP

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

siddharthsoam
Partner - Creator II
Partner - Creator II
Author

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 ?

Brett_Bleess
Former Employee
Former Employee

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

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.