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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
apoorvasd
Creator II
Creator II

Week number issue when week start made to Sunday

Hello everyone,

I have tried changing week start to Sunday using this code: WeekStart(Datefield, 0, -1) as WeekStart and this works as expected. When I choose a particular week number, it displays dates starting from Sunday of that week until Saturday which is fine. But the problem is, when I choose the last week (say, week 53) in a particular year (say, 2015) I don't see all 7 dates, as few dates would belong to next year. I would like to include these dates also into previous week. How can this be achieved?

Attached in my example, When I choose, week 53 of 2015, would like to include 1st and 2nd Jan of 2016 too.

Thank you.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

27 Replies
Anonymous
Not applicable

did you try weekyear(date) for your year field?!?

MK_QSL
MVP
MVP

Check WeekYear function

MK_QSL
MVP
MVP

Week(DateField) & '-' & WeekYear(DateField) as WeekYear

apoorvasd
Creator II
Creator II
Author

Thanks for the response.

Weekyear.PNG

I just added that piece of code to my script and this is what I see. Is there something else that i have to add to my script?

MK_QSL
MVP
MVP

Week(TempOrderDate+1) & '-' & WeekYear(TempOrderDate+1) as OrderWeekYear

Change field names accordingly.

apoorvasd
Creator II
Creator II
Author

It still shows the same thing.

Weekyear.PNG

MK_QSL
MVP
MVP

What are the dates you are looking for?

apoorvasd
Creator II
Creator II
Author

When I choose Week 53 of 2015, i have to see the following dates in my date field:

12/27/2015

12/28/2015

12/29/2015

12/30/2015

12/31/2015

1/1/2016

1/2/2016

MK_QSL
MVP
MVP

By using this...

Week(TempOrderDate+1) & '-' & WeekYear(TempOrderDate+1) as OrderWeekYear

I got what you are looking for.

Don't use WeekStart or anthing else.. If you are still not getting, upload your sample app