Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Daniel29195
Contributor III
Contributor III

While in load statment - behind the scene

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,

Labels (3)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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 

rwunderlich_0-1665239797905.png

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. 

rwunderlich_1-1665240069167.png

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

 

View solution in original post

1 Reply
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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 

rwunderlich_0-1665239797905.png

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. 

rwunderlich_1-1665240069167.png

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com