How to sort by multiple columns in Power BI [Table Visual Examples]

In this Power Bi tutorial, we will see how to sort by multiple columns in Power BI. In addition, we will also see how to sort columns alphabetically order and in descending order in Microsoft Power BI. Also covered below topics:

  • How to sort by multiple columns in Powert Table Visual
  • Sort by multiple columns DAX in Power BI
  • Power BI sort by multiple columns matrix
  • Power BI matrix sort columns Descending
  • Power BI matrix sort columns by value

Here, we will use a Power BI table visual and we will sort the table by multiple columns in Power BI.

Power BI sorts by multiple columns in Table Visual

Here we will see how to sort by multiple columns in the Power BI Table visual.

In this example, we use the Team Appearances table data to sort multiple columns for the table visualization in Power Bi.

Follow the below-mentioned steps:

  • Initially, log in to the Power Bi desktop and load the data into it using the get data option.
  • From the visualization, select the table visual, then drag and drop the values of the field from the field pane as below:
Power BI sort by multiple columns
Power BI sort by multiple columns

Here we will sort by multiple columns for the below-mentioned column names:

  • Teams
  • Winning Time Count
  • Press Shift + Left Click on the Column Header for which we want to apply Multiple Sort.
  • Here, we will select the Teams Column with Shift + Left Click. In the screenshot below, You can see, first, it sorts the data based on the Teams and then it sorted data for the Winning Time Count column.
Power BI sort by multiple columns example
Power BI sorts by multiple columns example
  • Now in the same way, if we want to sort the Team Id column, Press Shift + Left Click on the Column Header.
  • It sorts the Team Id column with multiple columns presented in the table visual in Power Bi.
Example of Power BI sort by multiple columns
Example of Power BI sort by multiple columns

This is how to sort by multiple columns in a Power BI report.

Power BI sorts by multiple columns in the matrix

Let us see how to sort by multiple columns in the matrix visual in Power Bi,

No, in the Matrix visual, it is not possible to sort multiple columns in the Power Bi report.

To sort the single column in the Matrix visual, follow the below steps:

  • Load the data into the Power bi desktop using the get data option. From the visualization, select the matrix visual, then drag and drop the values of the field from the field pane as below:
Power BI sort by multiple columns in the matrix
Power BI sort by multiple columns in the matrix
  • Here we will sort Team Id columns for that Press Shift + Left Click on the Column Header to apply the sort on the matrix visual.
  • In the screenshot below, You can see, first, it sorts the Team Id column presented in the Power Bi report matrix visual.
Example of Power BI sort by multiple columns in the matrix
Example of Power BI sort by multiple columns in the matrix

This is how to sort by multiple columns in matrix visual in a Power Bi report.

Check out the Power BI sort table by Date

Power BI sorts columns alphabetically

Let us see how to sort by columns alphabetically in Power Bi,

  • In the previous heading, as we discussed load the data into the Power Bi desktop.
  • Then click on transform data from the ribbon on the power bi desktop, it will redirect to the power query editor.
Power BI sort columns alphabetically
Power BI sort columns alphabetically
  • In the Power Query editor, choose the column for which you want to sort alphabetically and right-click on the column and choose the sort ascending option and click on the ok button, it will sort and display the column alphabetically.
  • In this example, we will sort the team’s columns alphabetically as highlighted below:
Power BI sort columns alphabetically example
Power BI sorts columns alphabetically example
  • In the below screenshot, you can see that the value has been expanded and displayed as below: Now click on the close and apply the option to save the changes.
Example of Power BI sort columns alphabetically example
Example of Power BI sort columns alphabetically example

This is how to sort by columns alphabetically in Power Bi.

Power BI sort by column descending

Let us see how to sort by columns in descending order in Power Bi,

  • Load data using the get data option into the Power Bi desktop. Then click on transform data from the ribbon on the power bi desktop, it will redirect to the power query editor.
Power BI sort columns alphabetically
Power BI sort columns descending
  • In the Power Query editor, choose the column for which you want to sort descending and right-click on the column and choose the sort descending option and click on the ok button, it will sort and display the column in descending order.
  • In this example, we will sort the team’s columns in descending order as highlighted below:
Power BI sort by column descending
Power BI sorts by column descending

In the below screenshot, you can see that the value has been expanded and displayed as below: Now click on the close and apply the option to save the changes.

Power BI sort by column descending example
Power BI sort by column descending example

This is how to sort by columns in descending order in Power Bi.

Power bi sort by multiple columns dax

Now we will see how to sort by multiple columns using the Power Bi Dax in Power Bi.

  • Load the data table into the Power Bi desktop using the get data option, click on the new measure option presented under the modeling tab, and apply the below-mentioned formula.
Sort columns = RANKX(ALL('Team A'),CALCULATE(MAX('Team A'[Winning Time Count])),,ASC,Dense)

Where,

  1. Sort columns = New measure name
  2. RANKX = Function Name
  3. Team A = Table Name
  4. Winning Time Count = Column Name
  • Select the table visual from the visualization pane. In the value field drag and drop the Teams, Team ID, and Winning Time count fields and also the created measure value as shown below:
Power bi sort by multiple columns dax
Power bi sort by multiple columns dax
  • Select the ellipsis icon (…) at the top right of the table visual. Then choose sort by -> Sort Columns.
  • It will sort the multiple columns presented in the table visual based on the created measure value., in ascending order as highlighted below:
Power bi sort by multiple columns dax example
Power bi sort by multiple columns dax example

This is how to sort multiple columns using the Power Bi Dax in Power Bi.

Power BI matrix sort columns by value

Now, let us see an example of how to sort columns by value in Power BI matrix visual.

In this example, we use the financials excel sheet to sort multiple columns for the matrix visualization in Power Bi.

  • Load the data into the Power Bi desktop using the get data option, and select the matrix visual from the visualization.
  • Drag and drop the field values from the field pane as shown below:
Power BI matrix sort columns Descending
Power BI matrix sort columns Descending
  • Now to sort the columns based on the sales value field, click on the ellipsis icon (…) and select the sort by option and choose the sales value as highlighted below:
Power BI matrix sort columns by values
Power BI matrix sort columns by values

In the below screenshot, you can see that sales values presented in the matrix visual have been sorted by multiple columns in Power Bi.

Power BI matrix sort columns by value
Power BI matrix sort columns by value

This is how to sort columns by value in the Power BI matrix visual.

This Power Bi article clearly showed how to sort by multiple columns in Power BI. In addition, we will also see how to sort by columns alphabetically order and in descending order in Power BI. Also covered below points:

  • Power BI sort by multiple columns in Table Visual
  • Power BI sort by multiple columns DAX
  • Power BI sort by multiple columns matrix
  • Power BI matrix sort columns Descending
  • Power BI matrix sort columns by value

You may like the following Power BI tutorials:

>