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!

One Reply to “Sorting by a measure not part of the visual in Power BI”

  1. Thank you for sharing these tips. I am attempting to sort a table visual by a column whose data I don’t want to see. Here’s my problem though … I have enabled text wrapping on the column headers. I need it for the other columns, and (so far as I can tell) I can’t differentiate that format by column/field. When I attempt to hide the sort column by narrowing it, the height of the header row increases. Any thoughts on how to address this?

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.