Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

For each loop while add load

Hi everybody

I have studied the related topics to my Theme, but still don't have a clear answer for my question. Is it possible to make the for each loop work, if you have add load?

I have something like this:

let var = file1, file2, file3

for each file in $(var)

tabletemp:

add load *

FROM $(var);

...

Wish you a nice day!

2 Replies

Re: For each loop while add load

This will be concatenated to the same table automatically by a QlikView phenomenon called ... AutoConcatenate. When the next LOAD detects a similar table layout as the last one, the new data will be concatenated to the resident table.

BTW to make it work, drop the add keyword, change FROM $(var) into FROM $(file) and add a NEXT keyword to the end

However, there may be situations where this trick refuses to work (I got a couple of cases that were very RAM-dependent, and some may have been hampered by other things in QlikView not working altogether well)). To make sure that it works under all circumstanctes, you can force concatenation by using a $-sign expansion variable, like in:

LET var = 'file1', 'file2', 'file3'

LET vPrefix = 'tabletemp:';

FOR EACH file IN $(var)

  $(vPrefix)

  LOAD *

  FROM $(var);

  LET vPrefix = 'CONCATENATE (tabletemp)';

NEXT

The syntax checker will go crazy on the free variable. Don't worry, it'll still work out ok.

Peter

Not applicable

Re: For each loop while add load

thank you for the answer, Peter!   sorry for mistakes... I thought that when we use partial reload, we need to add ADD before loading -> add load, otherwise it won't work? My problem is that when I use partial reload, only first document from $(var) is opened but not the other two...

Community Browser