Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
SauGuad
Contributor II
Contributor II

How to determine Week Number according to the German Calendar?

Hi, 

I am creating a master calendar and stuck with Week Number creation.

I would like to be able to set the exact date to run the Week Number accoording to the German Calendar but need some support from the community.
 
For example in 2016:
Week Number 01: starts on 04 Jan 2016

Here is my master calendar script so far.

Where can I do it better?

Thanks for your tips&tricks in advance. 

Pia

-----------------------------------------------------------
Let vMinDate = NUM('2015-01-01');
Let vMaxDate = NUM('2050-12-31');
 
MasterCalendar:
Load 
DateNum,
    NUM(Year  (DateNum),'0000') &
    NUM(MONTH (DateNum),'00')   &
    NUM(DAY   (DateNum),'00') 
    as DateKey,
    
    DATE(DateNum, 'YYYY-MM-DD')         as DisplayDate,    //2020-12-31
    DATE(DateNum, 'WWWW')               as Day,                    //Thursday
    DATE(DateNum, 'WWW')                 as DayAbbr,              //Thu
    WEEK(DATE(DateNum))                 as YearWeekNbr,     //53
    DATE(DateNum, 'MMMM')               as Month,                //December
    MONTH(DateNum)                      as MonthNbr,              //12
    YEAR(DateNum)                       as YearNum,                 //2020
    YEAR(DateNum) & NUM(MONTH(DateNum)) as YearMonth;     //202012
    
Load
$(vMinDate) + (IterNo()) as DateNum
    AutoGenerate 1
    
    WHILE 
    $(vMinDate) + (IterNo()) <= $(vMaxDate);
    
STORE *
FROM MasterCalendar INTO 'lib://XXX/MasterCalendar.qvd' (QVD);
Labels (2)
1 Solution

Accepted Solutions
rubenmarin

Hi, this is affected by 2 script variables, usally localted at the beginning of the script: BrokenWeeks and FirstWeekDay, set both to zero and it should work as you expect.

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/NumberI...

https://help.qlik.com/es-ES/sense/May2024/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpret...

 

View solution in original post

1 Reply
rubenmarin

Hi, this is affected by 2 script variables, usally localted at the beginning of the script: BrokenWeeks and FirstWeekDay, set both to zero and it should work as you expect.

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/NumberI...

https://help.qlik.com/es-ES/sense/May2024/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpret...