Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am Loading a table of 4 Colums (With Data), i now need to add to this table but to add to it i need to run a loop (For ...To),
a) can this be done?
b) if so can someone help me with the code.
a) yes
b) I don't understand your requirement. What do you MEAN by "add to this table"? What are you adding? Rows? Columns? What is your source for what you're adding? What is the loop supposed to do for you?
Hi John,
Thanks,
the last entry in the table will be something like this:
X 200910 abc def
I need to create a loop that replicates this row but changes the period (200910) till the current period (201006), then places those records back into the same table.
Does that make sense, i am really new to qlikview, so please bear with me.
Thanks
There's probably a more clever way, and I'm not sure this is completely correct, but maybe something like this:
[NewRows]:
LOAD max(Month) as Month // figure out the maximum month in your data
RESIDENT Data
;
INNER JOIN ([NewRows]) // grab the other fields for this month
LOAD *
RESIDENT Data
;
RENAME Month TO MaxMonth
;
LEFT JOIN ([NewRows])
LOAD date(addmonths(MaxMonth,iterno()),'YYYYMM') as Month
AUTOGENERATE 1
WHILE addmonths(MaxMonth,iterno()) <= today() // this is the loop
;
DROP FIELD MaxMonth
;
CONCATENATE ([Data]) // add the new rows back to the other table
LOAD *
RESIDENT [NewRows]
;
DROP TABLE [NewRows] // and get rid of the temporary table
;
thanks