3 Replies Latest reply: May 11, 2017 3:29 PM by Robert Svebeck RSS

    If + Do While Script Load

    Samuel Lin

      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