Nested Sorting in Power BI

Nested sorting refers to sorting a dataset or chart by multiple columns or fields. This varies from regular sorting, which sorts by one field.

Example of Single Sort. Data sorted by SumSales

In nested sorting, the amount of fields/columns which can be sorted by can be endless, however the order in which the tables/charts are sorted is in a hierarchy.

Example of Nested Sort. Category and Sub-Category sorted alphabetically. State has been sorted within this by the amount of sales.

This enables sorting at a more granular level, providing further analysis across one criteria and then another across a group. This can provide easy comparison between groups within a field. For example, identifying sales values for a particular category of products, over a certain time period, by a certain employee. This provides ability to identifying trends, seasonal variations and high preforming categories, which enables things like targeted marketing and new strategies.

There are two ways in PBI to nested sort. The first way, only available in tables, is very simple and only requires clicking on fields. The order of the hierarchy should be determined and value which they should be sorted chosen. Then, starting at the highest level of granularity, hold SHIFT and click down the hierarchy which you would like to sort by. Finally, whilst still holding shift, click the values you want to sort by. When clicking on string fields, they will be ordered by default in alphabetical order.

To do more complex sorting within the fields, for example giving each category a specific order opposed to alphabetic or asc/desc, a field must be created from which PBI will order the fields. This is a common method over various data programs. Using Power Query or DAX to give a numeric value for each row in the desired order, then sorting by this column to get the desired sort order.

There are many ways to sort in DAX and PQ, using different functions and methods. The important thing to remember is that the DAX and PQ calculations can filter values, group values, order by different measures and provide different methods of ranking. All of these can be used to give the desired sort.

Author:
Beau Foletti
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab