Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables in a for Loop

hi I have two variables

Let vCurWeek = replace(WeekName(Today()), '/', '');
Let vLastWeek = Replace(WeekName(Today()-7), '/', '');

which gives me vCurWeek=201115 and vLastWeek=201114

now I want a loop

For i= 0 to 'End of period'

That means for Example if I consider 4 weeks[201114-201117)

How to use that variable in a loop like

For i= 0 to ($(vLastWeek)+4)-1

....

Next i

This does not work. Any idea?

Regards

Sravan

1 Solution

Accepted Solutions
fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi Sravan,

I'm not sure if I understood you, but the solution seems to be:

For i= $(vLastWeek) to ($(vLastWeek)+3)

....

Next i

Is this what you need?

Regards,

Fernando



View solution in original post

3 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi Sravan,

I'm not sure if I understood you, but the solution seems to be:

For i= $(vLastWeek) to ($(vLastWeek)+3)

....

Next i

Is this what you need?

Regards,

Fernando



Not applicable
Author

hi Fernando,

That was easy. Thanks! Sometime small things are overseen, I am trying on this.

http://community.qlik.com/forums/t/44199.aspx

can you help me realise?

Thanks once again.

Regards

Sravan

fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi Sravan,

glad to help.

One thing you must have in mind is when your end of period goes to the next year.

For example 201150 to 201202. The for loop wont work correctly, and you'll need no treat these situations.

Regards,

Fernando