Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannagr
Creator III
Creator III

WeekYear in Master Calendar

Hello, 

online I found that I can write the field "WeekYear" like this in the Master Calendar:

Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear

 

This calculates weeks from Mondays to Mondays, and as a result in some years, I get 53 weeks (for example, week 53 has both December and January in it).

I want to fix that in a way that if for example December 31 is Wednesday in Week 53, the rest of the days 
(which are January of next year) until next Monday as the script calculate, won't be taken into account.

 

In short, what I want to do is :

 

2020-01-30_16-52-48.png

So, week 1 should be 1-4 /Jan

week 2 should be 5-11/Jan

week 3 should be 12-18/Jan

week 4 should be 19-25/Jan

week 5 should be 26-31/Jan

 

and week 1 for Feb should be only 1/Feb

week 2 should be 2-8/Feb

 

etc, so there isn't any intersection of the weeks, leading to wrong averages in my case and misleading interpretations.

 

 

What should i do?

2 Replies
lanlizgu
Creator III
Creator III

I don't know if Qlik is able to do the week division that you want in an expression.

If not possible, You can do a process to obtain your expected calendar (for each day of the month obtain the week number inside that month (from 1 to 6 potential week number))

  1. You get the week number of each date
  2. Do an autonumeric for each week-year grouped by month-year. 
    1. Do a count for each month-year of weeks (you get the number of weeks for each month-year)
  3. You link 2 and 2.1 and you have the expected week

 

Thank you.

 

Best regards.

ioannagr
Creator III
Creator III
Author

Hello, 

thanks for your response.  I need this to work in a dynamic environment, so i'm not sure if this process (for each day of the month obtain the week number inside that month (from 1 to 6 potential week number) works for this 😞

Correct me if i'm wrong, maybe i misunderstood something?