Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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

Tags (2)
1 Solution

Accepted Solutions
fosuzuki
Valued Contributor II

Variables in a for Loop

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



3 Replies
fosuzuki
Valued Contributor II

Variables in a for Loop

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

Variables in a for Loop

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
Valued Contributor II

Variables in a for Loop

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

Community Browser