Tuesday, September 1, 2015

Sorting Textual Dates in Qlikview Chart

I have a chart with a calculated date dimension.  One of the issues I had in the past with original versions PowerPivot was that there was only 1 possible sort order based on display.

So what happens when Apr comes before Jan in a textual sort in Qlikview?

This calculated dimension expression takes advantage of the dual function to represent dates as numeric for sorting purposes:

=dual(month(MaturityDate) & '-' & Year(MaturityDate),Num(year(MaturityDate),'0000') & num(Month(MaturityDate),'00'))

By sorting numeric, this expression will show the proper sort order for dates. 

Helping threads here.
https://community.qlik.com/blogs/qlikviewdesignblog/2014/07/18/dual-exists-useful-functions
https://community.qlik.com/thread/58791