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

Sort order with year-month

Hello everyone,

I have a problem with the sort order in a bar chart. On the x-axis I have a field, let's call it MyYearWeek, which contains the following values:

2013-51

2014-1

2014-12

2014-2

My problem is that I don't know how to sort it correctly, right now with my A->Z sorting the values presents as 2013-51, 2014-1, 2014-12, 2014-2 of course... I really do want to keep the 'YYYY-WW' formatting for my field values. How to sort it within the chart object sort tab, without changing my script below... Perhaps I could use the Year field and Week field seperately for sorting?

My script:

Year(MyDate) As MyYear,

Week(MyDate) As MyWeek,
Year(MyDate) & '-' & Week(MyDate) As MyYearWeek

Thanks in advance.

Regards,

Filip

14 Replies
Not applicable
Author

Hi Filip,

Do you have to keep the format as YYYY-WW or can it be changed to YYYYWW?

if it can be changed, just use

Year(MyDate)*100+Week(MyDate) as MyYearWeek

instead of your original expression and then use numeric sort on the chart. It will work.

Thanks and BR.

Abhinava

Anonymous
Not applicable
Author

Thanks, works great.

Anonymous
Not applicable
Author

Thank you all for your help.

techvarun
Specialist II
Specialist II

Useful discussion. bookmarked it

vivek_batra
Partner - Contributor III
Partner - Contributor III

It solved my problem of sorting my X-Axis which is like MonthName-Year. Thanks