Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem in using variable in Loop

I couldn't run this script as it shows as

vMonthLoop =  to

in the debugger

I don't understand what's wrong with this,

Can anyone help to fix my script?

Thank You!

let vStartYear = Min(AccidentYear);

let vEndYear = Max(AccidentYear);

//*************************Finding the Max Development Month for each Year*********************************

FOR vMonthLoop = $(vStartYear) to $(vEndYear)

  Left Join(CTRNPF)

  LOAD

  max(DevelopmentMonth) AS MaxMonth$(vMonthLoop)

  Resident CTRNPF_Max where AccidentYear=$(vMonthLoop);

NEXT

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can't aggregate field values just like you've done in your vStartYear and vEndYear definitions.

You need to do the aggregations in a LOAD statement, then peek() the values from the table:

EXT:

LOAD Min(AccidentYear) as Min,

          Max(AccidentYear) asMax

Resident YourTablewithAccidentYear;

let vStartYear = Peek('Min',0,'EXT');

let vEndYear = Peek('Max',0,'EXT');


DROP TABLE EXT;

Check the variables in script debugger at this point. Both should hold numeric values.

View solution in original post

2 Replies
swuehl
MVP
MVP

You can't aggregate field values just like you've done in your vStartYear and vEndYear definitions.

You need to do the aggregations in a LOAD statement, then peek() the values from the table:

EXT:

LOAD Min(AccidentYear) as Min,

          Max(AccidentYear) asMax

Resident YourTablewithAccidentYear;

let vStartYear = Peek('Min',0,'EXT');

let vEndYear = Peek('Max',0,'EXT');


DROP TABLE EXT;

Check the variables in script debugger at this point. Both should hold numeric values.

Not applicable
Author

Thank You. It works!!!!