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

Looping while loading

Hi All,

I'm very new to Qlik, so please forgive me if I ask stoopid questions 🐵

I have loaded a table which has one record:

Month
01/01/2010 // date format dd/mm/yyyyy

Payment
100.00 // monthly payment

Number of payments
36 // number of months the payment will be made from the first date

I want to create this record in another table with 36 rows of data, one for each payment month.

So i want to code something like :

FOR i = 1 to $[Number of payments]

Insert into NEWTABLE

Month + i, // add number of months to the first date
Payment

NEXT i

Is this possible? Do you have any pointers as to where to find the code to implement this?

Many thanks & kind regards,
Phil

2 Replies
Miguel_Angel_Baeyens

Hello Phil,

I'd rather use something like

SET vNoPmts = PEEK('Number of Payments', 0, 'Name of table'); SET vPmtStartingMonth = PEEK('Month', 0, 'Name of table');
storing that "36" in one variable and month starting date in the other. You only need to change in the code above 'Name of the table' for the actual name. Peek function returns in this case first (0) value of field indicated in table.

Now you are able to

Payments:LOAD RowNo() AS PmtNo, AddMonths($(vPmtStartingMonth), RowNo()) AS DueDateAUTOGENERATE($(vNoPmts));


Please note that the code above is untested, so some changes may be neccesary.

Hope this shed some light in your needs.

Not applicable
Author

Hi Miguel,

Many thanks for your quick reply, this works perfectly!

Thank you very much for your help.

Phil