Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Problem whit month iteration (for...next)

Hello, i need to (monthly) iterate from InitMonth to ActualMonth but this code doesn't work

LET vActualMonth = Num(MonthStart(Today()));

LET vInitMonth = Num(MonthStart(AddMonths(vActualMonth, -2)));

FOR vLoopMonth = vInitMonth to vActualMonth step AddMonths(vLoopMonth, 1)

.

.

.

...

NEXT

Any help please?

If i skip the step expression i can iterate daily but i want to get a monthly iteration.

1 Reply
rwunderlich
Not applicable

Re: Problem whit month iteration (for...next)

The step expression is only evaluated once and it is an increment, so that approach won't work. Here's another approach.

LET vActualMonth = Num(MonthStart(Today()));

LET vInitMonth = Num(MonthStart(AddMonths(vActualMonth, -2)));

FOR i = 0 to 2

          LET vLoopMonth = AddMonths($(vInitMonth), $(i));

          // Do something with vLoopMonth

NEXT i

-Rob

http://robwunderlich.com