Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

for loop - help needed

Hi,

i am not expert on loops - could you please help me?

Attached i am sending a qvw with data and also xlsx spreadsheet.

Data i have is:

period               key            status           info

2013 08               A            revised          abc

2013 08               B            revised          def

2013 08               C            compl           ghi

2013 07               A            other             jkl

2013 07               B            compl           mno

2013 07               C            compl           prs

2013 06               A            compl           tuw

2013 06               B            compl           xyz


Now i would like to create a loop file that would:

1) check if in the line status is 'revised'

2) if yes - another loop is needed to go to a latest period where status for the same key was 'compl'

3) create a new column e.g. info2 where the value will be either the same as in column info (in case status is other than 'revised') or that would give value from info column from the latest period where the same key had status 'compl' .

So i would like to have:

period               key          status           info          info2

2013 08             A            revised        abc          tuw

2013 08            B            revised        def           mno

2013 08             C            compl           ghi            ghi

2013 07             A            other             jkl             jkl

2013 07             B            compl           mno        mno

2013 07             C            compl           prs            prs

2013 06            A            compl           tuw          tuw

2013 06             B            compl           xyz           xyz

I'll be grateful for help. Thanks

J.

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You don't need a loop. You can do it with regular load statements. See attached qvw. Note, the inline load is just an example to load some example date. Replace it with your load statement.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi G,

thanks for answer.

yes, i managed to obtain my result with normal load statements as well, just thought that loop would be more efficient in this case.
J.