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

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Have a different variable value for each loop

Hi all,

I would like to run some script on many data files of wich each 5 should result in a qvd file in a seperate folder. So what I would like to do is have a flat files in which I give the characteristics of this. Example:

Nr         FileName/TargetFolder

1               AD_EUR_1         

2               DR_USA_3

...               ....

17             APL_3_D

So based on this table I would like the script to run 17 times and have a variable based on the 'FileName/TargetFolder' that determines which files are loaded and where it stored. What I would like to know is how I can have the variable be different each run.

Thanks for your help!


Erik

4 Replies
Not applicable
Author

If I understand correctly you just want to create a simple loop, no?

LET vFileCount = NoOfRows('Files');

FOR i = 0 to $(vFileCount) - 1

    LET vFileName = Peek('FileName', $(i), 'Files');

    LET vTargetFolder = Peek('TargetFolder', $(i), 'Files');

    ...do your load here using the above variables...

NEXT i

Not applicable
Author

That's it indeed!

But, in my script there is a loop as well so now I have a nested loop. Will this work?

Not applicable
Author

Got it, its possible as long as you have the right extension after 'next'

Not applicable
Author

Sure, you can nest as many loops as you wish. You just need to create multiple variables to loop with.