How To Sort A Table Using Multiple Columns In Power BI

Overview

 
In this blog, we will learn how we can sort a table using multiple columns for the table visualization in Power BI.
 
This feature has been rolled out in March 2020 Power BI Desktop Update.
 
Here, first, we will learn how we can create and apply a sort for multiple columns. Then we will change the sort order for the column. Later on, we will also change the Sort Sequence for the table.
 
In this article, we will cover the following things.
  • Create Multi-Column Sort for table
  • Change Sort Order for Multi-Column Sort
  • Change Sort Sequence for the table
  • Limitations

Business Use Case

 
We have a table called “Sales” in our Power BI report. We need functionality where we need to sort our table first on “Item” and then, “Order Date” and “Representative”.
 
How To Sort A Table Using Multiple Columns In Power BI
 
So, now let’s get started!
 
Note
Make sure, you have updated your Power BI Desktop, with the latest version of March 2020.
 
The demo for the same concept is available here.
 

Create a Multi-Column Sort Table

 
Step 1
 
We want to first apply sort, on the following columns.
  • Item
  • Order Date
  • Rep
Press Shift + Left Click on the Header Column on which you wish to apply Multiple Sort.
 
Here, we will select the Order Date Column with Shift + Left Click.
 
You can see here, first, it sorts the data based on the Item and then it sorted data based on “Order Date” column.
 
How To Sort A Table Using Multiple Columns In Power BI
 
Step 2
 
Now, let’s apply sort on the “Rep” column.
 
To apply Sort on the “Rep” column, Apply Shift + Click on the “Rep” header column.
 
How To Sort A Table Using Multiple Columns In Power BI
 

Change Sort Order and Sort Sequence for the Multi Sort Column

 
Now, if we wish to change the Sort Order from Ascending to Descending, how can we achieve that requirement?
 
For that, apply Shift + Click on the same column where you have already applied sorting. This will also change the Sort Sequence.
 
Currently, as you can see in the below table our Sort Sequence is,
 
Item > Order Date > Rep
 
How To Sort A Table Using Multiple Columns In Power BI
 
Let’s say for an example,
 
We wish to change the Sort Order for the “OrderDate” column, then apply Shift + Click for the “OrderDate” column.
 
This will change Sort Order from ASC to DESC. With this, it also changed the Sort Sequence as well.
 
How To Sort A Table Using Multiple Columns In Power BI
 
Now, the Sort Sequence is,
 
Item > Rep > Order Date
 
How To Sort A Table Using Multiple Columns In Power BI
 
Limitations of Multi-Column Sort
  • We can’t remove the Sort from the applied column.
  • This is limited to table visualization only. This multi sort feature is not applicable for Matrix visualization.

Conclusion

 
This is how, we can apply Multi Sort on table columns, Change the Sort Order for Multiple Sort Columns and Change the Sort Order Sequence in Power BI.
 
Stay connected with me for more amazing articles!!
 
Happy Reporting!!