Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
luizcdepaula
Creator III
Creator III

WeekYear giving wrong year

Hello experts,

I believe that QlikSense might have an issue with the Master Calendar script.

I am applying the set variables below so that I set the week that contains the 4th day of January as the week 1. So the variables are set as below:

SET FirstWeekDay=6; (Sunday)

SET BrokenWeeks=0; (Unbroken Weeks)

SET ReferenceDay=4; (contain day 4 of January)

It supposed to work fine, but my results are giving me the date of the first Sunday of the year that contains the day 4 of January with the previous year (2015)

This is causing the fact data to recognize the week that starts on 1/10/2016 as the first Sunday of year 2016, and therefore the first week of the year. All my results are one week off.

Is there a bug in Qlik or it is a problem with the Master Calendar script?

Thanks in advance,

LD

12 Replies
swuehl
MVP
MVP

Can't see how you are linking this table or calculating the two other fields.

The calendar itself seems to work for me:

2016-08-15 22_42_22-Kalender.png

luizcdepaula
Creator III
Creator III
Author

Stefan,

It actually works fine. On our data source we are missing the first week of the year so it is not mapping.

I will work with the analyst to see how we can fill this gap.

Thank you for your help.

gileswalker
Creator
Creator

Using: Qlik Sense

I was having the exact same issue with the erroneous year outcome, under the same SET conditions:

SET FirstWeekDay=6;
//Setting Sunday as the week start
SET BrokenWeeks=0;
// Broken Weeks not allowed
SET ReferenceDay=4;
//Jan 4th always belongs to week 1

 

Seems the weekyear function still has a bug/anomaly that I can't fathom, where the function displays the year of the first day of the new year as the year prior:

gileswalker_0-1612825277384.png

2020 in pink above should be 2021.

The way I fixed it was quite simple in the end.  I have simply added a function the auto-calendar in the LOAD script ( I have also concatenated a week function to it for my own calendar):

gileswalker_1-1612825563741.png

 

The year part is simply:

weekyear(($1)+1)

So in the AutoCalendar the "$1" represents the date field in the app you have, and it's adding 1 day to the field, and then doing the weekyear logic from there.

I have done it, and then reconciled data outcomes to annual calendar transitions over several years, using this website as a link for the calendar matching my SET conditions, and its fine:

https://savvytime.com/week-number/united-states/2019

HTH someone else

Thanks

Giles