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.

chriys1337
Contributor II

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

Re: Rolling Number for Calendarweeks in Script

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;