Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Please see my challenge as below case, Thanks.
Now dimension:
if(GetFieldSelections(Periods)='Qtr',Qtr,[M o n t h])
Custom sorting:
if(GetFieldSelections(Periods)='Qtr',
Match(Qtr,'Q1','Q2','Q3','Q4'),
Match([M o n t h],'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'))
and other expression sorting was sorting on load order.
But sometimes, for example during the page loading , the order not works fine , also some other selections the order not works fine.
Is there any way I can do this custom sorting? Thanks.
Best Regards,
Haifeng
You can avoid custom sorting by doing either of these two things taking as an example your case of months and quarters:
All real dates in Qlik are dual in fact. So the date 27th of August 2018 has the text part according to your date format settings and the numeric part is 43339 (the number of days passed since 30th of December 1899).
You can create your own dual fields easily with the dual function as you saw above. If you have a quality field with for instance quality text descriptions and the ranking is not alphanumeric then you could to this:
Input:
Superior
High
Excellent
Medium
Low
Unacceptable
And you want them to sort correctly you would assign 1..6 in the order above.
In a load script this could be done explicitly like this:
LOAD
Dual( Quality , RowNo() ) AS Quality
INLINE [
Superior
High
Excellent
Medium
Low
Unacceptable
];
Calendar:
LOAD
Dual( Qtr , Match( 'Q1','Q2','Q3','Q4) ) AS Qtr, // you will still keep the text part but
Dual( Month , WildMatch('Jan*','Feb*',.......) AS Month // add a numeric part to sort out the sort order
/* Or */
Month( InvoiceDate ) AS Month // will be a dual-valued month field
....
More information about useful dual-related functions and the dual nature of Qlik fields and values:
Dua():
Text():
Num():