Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Todai
Contributor
Contributor

Sorting week of year - last 18 weeks and corresponding weeks previous year

Hi all,

Hope you are able to help me out on this.

In a line chart I am showing production per week (format WeekOfYear) for the last 18 weeks and the corresponding weeks the year before. So I have en expression for each of those.

Last 18 weeks:
sum({1<
MyDate={'>=$(=WeekStart(Today(),-18))<=$(=WeekEnd(Today(),-1))'}
,DateType={'ProductionDate'}
>}M_Units)

Previous year:
sum({1<
MyDate= {'>=$(=WeekStart(addyears(Today(),-1),-18))<=$(=WeekEnd(addyears(Today(),-1),-1))'}
,DateType={'ProductionDate'}
>}M_Units)

I'm using a canonical calendar (inspired by this post: https://community.qlik.com/t5/Qlik-Design-Blog/Canonical-Date/ba-p/1463578) and DateType is a field from my DateBridge table. As my dimension I am using a week-field from my canonical calendar.

My problem is: How do I sort my dimension correctly? As default it gets sorted numerically, which puts week 51 and 52 in the end when their actually should be first.
I want it to be sorted like shown in the mock-up below.

Graph_mockup.png

 

 

 

 

 

 


Unfortunately I'm not able to post my data or application.

Thank you in advance.

4 Replies
Anil_Babu_Samineni

How about adding Sort by expression as follows with Ascending order

Week(MyDate)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Todai
Contributor
Contributor
Author

Thank you for you response, but unfortunately your suggestion gives me the following result:

SortOrder.png

 

Anil_Babu_Samineni

If Week(MyDate) returns correct it should work as expected.

BTW, Can you simply put same dimension in Sort by expression and try with some options?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Todai
Contributor
Contributor
Author

I just remembered, that I'm using a canonical calendar inspired by this:
https://community.qlik.com/t5/Qlik-Design-Blog/Canonical-Date/ba-p/1463578
(I have updated my original post with this info now)

And I guess that affects how sorting works but I'm not quite sure how.