Search code examples
sortingdimensionqlikview

Interactive chart sorting in Qlikview


I have a barchart in Qlikview where my x-axis is set by a selection (using a calculated dimension) to be either date or station. Is there a way for the sort order to be defined by the selection of x-axis.

Specifically, I would like the chart to sort by date when the x-axis is date, but to be sorted by the value of the expression when the x-axis is station.


Solution

  • Perhaps you could try a expression for the "sort-by" option for your calculated dimension? I am not sure how your calculated dimension is defined, however, it may be possible to use part of it to define the expression which sorts your calculated dimension.

    In the below example, I made a guess at your calculated dimension and then defined a "Sort-by" expression:

    The "Sort" tab of the chart properties in QlikView

    In this example, my expression was:

    =if(GetFieldSelections(XAxisSelection)='date',date,<your value expression>))
    

    Here <your value expression> would be whatever expression you defined in the Expressions tab (e.g. =sum(value))

    This appears to fulfil what you need, the sort order changes depending on the value selected for XAxisSelection, either sorting by date or by expression value (extra tip: if you need your sort order to be ascending for date, but descending for your value, you could multiply your value expression by -1).