Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
chriys1337
Creator III
Creator III

Rolling Number for Calendarweeks in Script

Hi,

I am having two Year Week Fields with the Format YYYYWW and with the following script I have identified the Min and the Max Year.

Temp_Date: 
Load 
left(min([kick-IN]),4) as minDate
left(max([kick-OUT]),4) as maxDate 
Resident opportunity_table; 

LET vL.VarMinDate = Num(Peek('minDate', 0, 'Temp_Date'));  // 2015
LET vl.VarMaxDate = Num(Peek('maxDate', 0, 'Temp_Date'));   // 2019

Now I would like to generate for each year (2015-2019) all existing calendarweeks, I know that 2015 has 53 weeks and the other years just 52 weeks AND start from 201501 with a rolling number (1) till the end of 201952 (261).

Does anybody have an idea how to script this, maybe with a for loop with if condition?

Thx for your help!

1 Reply
sunny_talwar

Have you tried with AutoNumber() function or Peek/Previous?

LOAD AutoNumber(YearWeekField) as RollingCounter,

    If(YearWeekField = Previous(YearWeekField), Peek('RollingCounter2'), RangeSum(Peek('RollingCounter2'), 1)) as RollingCounter2,

    ....

FROM ....

Order By YearWeekField;