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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Week() beyond 52 weeks?

Hi again,

Is there a way to make week() go beyond a 1 year period? I need to display week numbers from a range of more than 3 years, so I need to make the week count go above 100. Anyone know an easy way to do this? Thanks.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

That won't work. Let's say you want to start counting weeks from Monday, December 31, 2007, which QlikView considers week 1 of 2008:

December 31, 2007 -> 1
January 1, 2008 -> 2
January 7, 2008 -> 4
December 28, 2008 -> 104
December 29, 2008 -> 2
January 1, 2009 -> 3
January 5, 2009 -> 6
December 31, 2009 -> 159
January 1, 2010 -> 212

I'd recommend this (replacing the date with whatever starting date you want):

1+floor((Date-date#(20071231,'YYYYMMDD'))/7)

View solution in original post

4 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

How about:

Get the start year stored in Start_Year variable, something like min(year(Date)) and then

LOAD week(Date) * (year(Date) - $(Start_Year) + 1) as BigWeekNumber

Just an idea.

johnw
Champion III
Champion III

That won't work. Let's say you want to start counting weeks from Monday, December 31, 2007, which QlikView considers week 1 of 2008:

December 31, 2007 -> 1
January 1, 2008 -> 2
January 7, 2008 -> 4
December 28, 2008 -> 104
December 29, 2008 -> 2
January 1, 2009 -> 3
January 5, 2009 -> 6
December 31, 2009 -> 159
January 1, 2010 -> 212

I'd recommend this (replacing the date with whatever starting date you want):

1+floor((Date-date#(20071231,'YYYYMMDD'))/7)

disqr_rm
Partner - Specialist III
Partner - Specialist III

Sure, but on the other hand, I just gave an idea and not a 100% solution. I expect members to do some homework themselves.

This "week" thing is pretty tricky and discussion cen be little sensitive based on requirements. Remember our favorite thread http://community.qlik.com/forums/p/18218/71427.aspx#71427 ? Smile

johnw
Champion III
Champion III

Eep! Don't remind me! Embarrassed Wink