Sorting by a measure not part of the visual in Power BI

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 Smile.

So lets start with the simple one, I want to sort a chart on a measure not part of the visual. Let’s take this visual:
image

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:

image

Now in the sorting option I can also pick ListPrice:

image

And now the result sorted by ListPrice:

image

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.

image

The trick here is to add listprice to the matrix and sort by it:

image

And finally hide the column by just dragging the column width to be very small:

image

Et voila. Pretty neat tricks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.