Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
d_koti24
Creator II
Creator II

Custom sorting

i have a month field.how to sort the month field  like -----jan,feb,mar,....dec .

7 Replies
ecolomer
Master II
Master II

This ordenation is natural by default.

You can also select order by MonthNo(month)  in Ordenation Label,

its_anandrjs

It will sort by default ascending order or also you can use Sort option from the chart properties.

Sortoptions.png

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

They will sort properly if they were created as dual() values. You would get a dual value if you used the month() function to extract from a date.

If the months come to you as a text value, you can create a proper dual like this:

month(Date#(monthField','MMM'))

-Rob

d_koti24
Creator II
Creator II
Author

i wrote like this,its working fine.but i ve a small doubt,is there any performance issue by writing like this,

if(month='jan',1,if(month='feb',2,if(month='mar',3,if(month='apr',4,if(month='may',5,if(month='jun',6,if(month='july',7,if(month='aug',8,if(month='sep',9,if(month='oct',10,if(month='nov',11,12)))))))))))

its_anandrjs

Yes might be you can use any sort order field also for this but you need to load a simple inline table in the load script and connect it with the month field see the example please.

Fact:

LOAD * Inline

[

Month

apr

may

sep

oct

jun

jan

feb

mar

jul

aug

nov

dec

];

OrderTable:

LOAD * Inline

[

Month,SortOrder

jan,1

feb,2

mar,3

apr,4

may,5

jun,6

jul,7

aug,8

sep,9

oct,10

nov,11

dec,12

];

And you get

Sortorder.png

This can be done in any chart but with the help of the Expression sort order by using the SortOrder field in the expression box

ExprSorder.png

Regards

Anand

SunilChauhan
Champion II
Champion II

yes if are memory intensive .they degrade the performance of application.

you could use

Match or mixmatch(Month,'jan','feb','mar','apr',.....................................)

or use inline query like anand in script(Control +E).

even sort expressions are degrading the performance.

you could try to sort in script itself.

hope this helps

Sunil Chauhan
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Your example if() statement is probably the worst performing of the various suggestions here. But fine if it works for you.

Another approach to sorting is to load the values in the order you want and then use "load order" for sort. Here's an explanation and example.

http://qlikviewcookbook.com/2012/11/establishing-a-sort-order/

-Rob

http://masterssummit.com

http://robwunderlich.com