Every now and then this request comes up, I want to sort by a measure that is not part of the visual. Even though it is not “visualization” best practice sometimes the job requires it anyway .
Now instead of sorting by OrderQuantity I want to sort by the ListPrice. The trick here is to make the measure part of the query, and one way you can do that is by adding it to the tooltip. As such:
Now in the sorting option I can also pick ListPrice:
And now the result sorted by ListPrice:
Pretty cool right ! Apparently this trick has been around for some time but I didn’t know until Will and Amanda told me.
Ok next up is sorting in a matrix \ table. This same trick doesn’t work there, although again we need to make it part of the query.
Let’s take the same table of data but now in a matrix, and I also want to sort on ListPrice here.
The trick here is to add listprice to the matrix and sort by it:
And finally hide the column by just dragging the column width to be very small:
Et voila. Pretty neat tricks!