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: 
Anonymous
Not applicable

How to create a table based on data from an existing table in script

Hi,

Is it possible to create the right table based on the existing table on the left in a script ?

My guess is that it can be done with For..Next.

This is what I need:

There is an record in an existing table with ID=A, start Date=June, Units=4 and Value =100.

Based on this I would like to create a new table which has 4 (=Units) lines, each with an amount of Value/Units and a date which starts at the start date and increases with 1 month

  Snap31.png

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

LOAD ID,AddMonths(Date#(StartDate,'1-MMM'),IterNo()-1) as StartDate, Value/Units as Amount

Resident OPPS      // if already loaded or  From Path\Table.xls or From DB_Table

While IterNo() <= Units;

View solution in original post

5 Replies
tomasz_tru
Specialist
Specialist

Is there an upper limit for the unit field?

Tomasz

antoniotiman
Master III
Master III

Hi Eric,

LOAD ID,AddMonths(Date#(StartDate,'1-MMM'),IterNo()-1) as StartDate,
Value/Units as Amount
Inline [
ID,StartDate,Units,Value
A,1-jun,4,100
B,1-feb,2,200
C,1-jul,3,90]

While IterNo() <= Units
;

Regards,

Antonio

Anonymous
Not applicable
Author

Not perse, but I don't expect it to be more than 36 (months)

Anonymous
Not applicable
Author

Hi Antonio,

Not sure if I understand this fully. You put in the values of the existing table within the Inline statement ( A,1-jun,4,100
B,1-feb,2,200 and  C,1-jul,3,90 ).

I need to replace this part of script by a reference to the Existing table as It need to read these lines from the table, right ?

Imagine the existing table name is : OPPS, how should the script look like ?

antoniotiman
Master III
Master III

LOAD ID,AddMonths(Date#(StartDate,'1-MMM'),IterNo()-1) as StartDate, Value/Units as Amount

Resident OPPS      // if already loaded or  From Path\Table.xls or From DB_Table

While IterNo() <= Units;