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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

For Loop to load incremental numbers

I am working on a dashboard to load values in between Start and End (specifically postal codes). I am doing testing now, but I can't get it to work. I know it must be a combination of the loop and concatenated loading but I just can't figure it out. See my sample code below. I would want my output to be essentially. Thanks!

Postal Code

10

11

12

13

14

15

16

17

18

19

20

Range:

LOAD * INLINE [

    Start, End

    10, 20

];

let x = FieldValue('Start',1);

let y = FieldValue('End',1);

for i=$(x) to $(y)

Postal_Codes:

load *,

i  as Postal_Code

Resident Range;

next i;

drop table Range;

Labels (1)
1 Reply
swuehl
Champion III
Champion III

You need to evaluate your variable in the LOAD  like

...

$(i) as Postal_Code

...

Another way to create your sequence would be

Range:

LOAD * INLINE [

    Start, End

    10, 20

];

let x = FieldValue('Start',1);

let y = FieldValue('End',1);

Postal_Codes:

LOAD $(x)+recno()-1 as Postal_Code

autogenerate $(y)-$(x)+1;

drop table Range;