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: 
Ling12345
Contributor
Contributor

RowNo() with While loop continues to loop after While condition is not satisfied

Hi 

I've noticed that IterNo() and RowNo() seem to behave differently with While loop conditions. Using the following script, the IterNo table produces numbers up to 3 as expected based on the While condition, but the RowNo table produces numbers up to 4, which means that it loops once when the While condition is not satisfied. 

Is this due to a difference in execution order of the two scripts, or is this just a bug in Qlik? 

Thanks!

[Original Number]:
LOAD * INLINE [
Original No
1
2
3
];

[IterNo]:
LOAD
[Original No]
,[Original No] + IterNo() -1 AS IterNo
RESIDENT [Original Number]
WHILE [Original No] + IterNo() -1 <= 3
;

[RowNo]:
LOAD
[Original No]
,[Original No] + RowNo() - 1 AS RowNo
RESIDENT [Original Number]
WHILE [Original No] + RowNo() - 1 <= 3
;

Labels (1)
2 Replies
eddie_wagt
Partner - Creator III
Partner - Creator III

Ling12345
Contributor
Contributor
Author

Thanks Eddie. That post explains the difference between the functions conceptually, but doesn't explain why the iteration is continuing when the While condition is no longer satisfied for the script using RowNo() ?