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

If + Do While Script Load

Hi Qlikers,

I have the following table:

Code   Parent_Code

1         

2

3          1

4          2

5          3

6          4

7          6

the goal is to lookup the original parent code (i.e. Parent_Code is empty, where in this example just 1 and 2), but the Parent_Code are "Nested".

For example, Code=5's Parent_Code is 3, and 3's Parent_Code is 1, so 1 should be the "Final_Code". I want to generate the Final_Code for all the Code

I kind of know what I need to do, just not familiar with the syntax and scripting language

for i = 0 to row(table)-1

     do while not empty(Parent_Code)

     Lookup the ParentCode and assign it as the TemporaryFinalCode...


Does anyone has input on how to make the lookup work? or any other scripting loop may achieve this?


Thank ou so much,

Samuel

3 Replies
sunny_talwar

samuel_lin
Creator
Creator
Author

Hi Sunny,

Eventually I am mapping the final code to some kind of channel, so another table as:

Final_Code    Channel

1                     Channel1                  

2                     Channel2

3                     Channel3

4                     Channel4

I am still trying to understand hierarchy load, but don't think that would help to map to the Channel level?

Thanks 

RSvebeck
Specialist
Specialist

Check out HierarchyBelongsTo, it will work well for this.


Robert


Svebeck Consulting AB