
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
do loop not working as expected
I am new to qlik sense and i am trying to use below do loop to create a simple table. But table is not getting created although code is running successfully. Can someone please explain why table is not getting created.
table:
let a=1;
do while (a<=5)
load a;
a=a+1;
loop;
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As below, the table creation must be within the loop, not outside the loop
1) Using Do While
let a=1;
Do while a<10
Table:
LOAD $(a) as field
AutoGenerate 1;
Let a=a+1;
Loop
1) Using only start and end variables
LET vstart = 1;
LET vend = 10;
Table:
lOAD $(vstart)+ITERNO()-1 as field
AutoGenerate 1
WHILE $(vstart)+ITERNO()-1 <= $(vend);
If a post helps to resolve your issue, please accept it as a Solution.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As below, the table creation must be within the loop, not outside the loop
1) Using Do While
let a=1;
Do while a<10
Table:
LOAD $(a) as field
AutoGenerate 1;
Let a=a+1;
Loop
1) Using only start and end variables
LET vstart = 1;
LET vend = 10;
Table:
lOAD $(vstart)+ITERNO()-1 as field
AutoGenerate 1
WHILE $(vstart)+ITERNO()-1 <= $(vend);
If a post helps to resolve your issue, please accept it as a Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vineeth,
Thanks for your reply and your solution is working fine
Table creation outside the loop is also working fine. Does placement of tablename: really make difference?
Table1:
let a=1;
Do while a<10
LOAD $(a) as field
AutoGenerate 1;
Let a=a+1;
Loop
