Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
SCRIPT 1 :
let starting_date = num('2020-01-01');
load
date(num($(starting_date)) + iterno() - 1,'YYYY-MM-DD') as date
autogenerate 2
while date(num($(starting_date)) + iterno() - 1,'YYYY-MM-DD') <=num('2020-01-10');
execution flow of the above code :
correct me if im wrong, but here i think the while works on a record per record base, this means, record is generated , after each rercord generated, the while is checked.
create record value --> generate 2 rows(in example above) for the record --> while condition.
SCRIPT 2 :
LOAD
customer_id,
customer_acct_num,
iterno()
FROM [lib://data/FoodMart+CSV+Files/example.csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
while iterno() <=2
;
if we have 4 rows in the csv file ,
what is the execution flow of the above code ?
by that i mean, does the while condition works base on av row per row this mean, script read first row, then check condition, if true reread, if not go to row 2 in csv file ?
OR
does the while condition works base on full read of the rows ? this mean, script read all 4 rows in the csv file, then check condition , if true , reread full csv file once again, if not then stop execution ?
hope my question makes sense,
thanks in advance,
The While loop is executed for one input row at at time. You can see this by adding a couple of fields - RecNo() for input row and RowNo() for output row.
Looking first at your CSV question. As an example, I'll use an Inline.
Load *,
RecNo() as RecNo,
RowNo() as RowNo
Inline [
F1
A
B
]
While IterNo() <= 2;
The output is
Returning to your loop example. Only one input record, not two, is generated before the While condition is tested. Adding RecNo and RowNo to your example give this output.
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com
The While loop is executed for one input row at at time. You can see this by adding a couple of fields - RecNo() for input row and RowNo() for output row.
Looking first at your CSV question. As an example, I'll use an Inline.
Load *,
RecNo() as RecNo,
RowNo() as RowNo
Inline [
F1
A
B
]
While IterNo() <= 2;
The output is
Returning to your loop example. Only one input record, not two, is generated before the While condition is tested. Adding RecNo and RowNo to your example give this output.
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com