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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
david_ze
Partner - Contributor III
Partner - Contributor III

Wrong result from 'week' function

Hi all,
I'm using the 'week' function to retrive the week number of a date.
When the field's data is '01/01/2011' the result is '52'...!

I'll appreciate if someone can reply me with the reson for this, and also the proposed solution.

Thanks in advance,
David

9 Replies
swuehl
MVP
MVP

Hi

Qlikview User IMHO the ISO definition for week numbering which is e.g. different from the one used in US I believe.

Week 1 is the week containig the first würdest oft the year.

Hope this helps,

Stefan

P.S. If you need different numbering, search the forum, I believe there are samples for Most Standard Systems.

Not applicable

Hi 52 is the last week of 2010.

1/1/2011 falls down in that week.

Try to catch this week during load andchange with 1.

C u,

Stefano

swuehl
MVP
MVP

Damn Mobile..

I meant the week with the first thursday oft a year is week number  1.

Regards

Stefan

mazacini
Creator III
Creator III

swuehl wrote:

Damn Mobile..

I meant the week with the first thursday oft a year is week number  1.

Regards

Stefan


With this infomration , I think I was able to sort this problem which I faced myself.

So I simply changed the script from

Week(Date) as Week

to

Week(Date+2) as Week

Seems to work!

swuehl
MVP
MVP

I don't think that this will work in general.

Maybe you want to check out the compilation of different week numbering standards that John has posted some time ago:

http://community.qlik.com/message/72204

Regards,

Stefan

Not applicable

Hi,

David,

this will solve your problem

num(subfield(LunarWeekName ('1/1/2011'),'/' ,2))

Please check correct if you got ur answer

sivarajs
Specialist II
Specialist II

Try this

IF ((DayNumberOfYear(date)) < 7 and week(date) > 2 , 1 ,  week(date#( date, 'DD/MM/YYYY')))

Sivaraj S

Not applicable

I had the same issue and did not like how it was displaying so I used this formula. Not the most elegant or exact, but I works for me:

if(week(CalendarDate)>50 and month(CalendarDate)<10,1,week(CalendarDate)) as 'Calendar Week',

I just had issues with the sorting, not so much with the 52.

Not applicable

Definitely not elegant but it does work to avoid jumps on bar chart from one year to another.

Thanks !