Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sohb2015
Contributor III
Contributor III

Sort Order in expression

Hello,

I have a calculated dimension which is used in bar chart. The dimension is the combination of Month and Year fields.

I want to sort the calculated dimension according to the calendar. i.e. Jan 15, Feb 15, Mar 15....Jan 16, Feb 16.

What expression should I write while trying to sort the column.

Thanks

5 Replies
sunny_talwar

Are you combining the Month and Year on the front end or back end?

veidlburkhard
Creator III
Creator III

Hi Sohini,

for sorting Month and Year you can use this expression: YY² + Num(Month)

As long as YY is greater or equal than 12 this works fine ascending or descending.

Hope this helps

Burkhard

johnw
Champion III
Champion III

I'd make a Month Year dimension defined as a date with a MMM YY format, and just sort numerically.

date(makedate(Year,Month),'MMM YY') as [Month Year]

If you really want to do it as a calculated dimension, again, just make it a date with a MMM YY format, and sort numerically.

=date(makedate(Year,Month),'MMM YY')

I try to avoid both calculated dimensions and sort expressions where practical.

Not applicable

Instead of adding date sort expression, simply create the Calendar table from ascending values and select Load order.

Otherwise add the Month No like 1,2,3 on the Master Calendar and use the Month No in your sort expression.

vikasmahajan

Add Calendar and sort on MonthNumber

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.