Have you ever tried to sort column headers in a Power BI matrix visual? There is no sort option available in the Matrix visual to sort the column headers, like row sorting.
While researching this, I discovered that there was no clear explanation in one place. I thought I would share my experience in this tutorial clearly.
In this tutorial, I will explain how to sort a matrix table column header in Power BI Desktop.
Sort Column Headers in Matrix Table Power BI [Sort Date Columns Descending]
I have created a Matrix visual in my Power BI report, with the ‘Sales‘ data, where the Rows represent the ‘Product‘, Columns represent the ‘Year‘ field, and Values represent the ‘Sales Amount‘.
You can refer to the image below, where the column headers [Year] are in the order of 2022, 2023, 2024, and 2025.

Now, my requirement is to sort the matrix table by column headers in the order of [2025, 2024, 2023, 2022].
Since we cannot sort the column headers by any sort option, we can create a custom sort using the Index column. First, we need to create a table with Year values (2022, 2023, 2024, 2025) and an index column.
Follow the steps below:
- To create a table in Power BI Desktop, click the Enter Data icon on the Home tab. Then, the ‘Create table‘ window will open, with all the years in a table. Click on the ‘Edit‘ button.

- Then, it will navigate to another page, where you need to add an Index column to the table. Click on the Add Column tab -> Click on the drop-down of Index Column. Select From 1 option. You can refer to the screenshot below:

Now, the table will be created with the years along with the index values, and it will be present under the Data Pane.

Then, exit the Power Query Edit mode.
- After that, click on the ‘Table view‘ on the left side, select ‘Year‘ values in the column in the new table. Go to ‘Column tools‘ tab -> Select ‘Sort by column‘ option -> Select Index.


Thus, the Year values will be sorted according to their index numbers. Therefore, we need to establish a relationship between the Matrix table and the support table [Index] that we have created.
- In the final step, click on the Model View tab, then click on ‘Manage Relationship‘ and add a relationship between the Matrix table and the Support table as shown in the image below.
- From Table – Select your Matrix table.
- To Table – Select the support table that you have created.
- Cardinality – Choose Many-to-one(*:1).
Select the Year column present in the support table, and it will show the cardinality option. Click on the Save button.

Thus, the relationship will be established between them.
- Now, return to the Report view, select the Matrix table, and replace the ‘Replace Columns‘ value with ‘Year‘ from the support table. Have a look at the image below.

- Now, it will display the sorting order of column headers in the matrix visual in a specific order, such as [2025, 2024, 2023, 2022]. Have a look at the reference image below.

This is how to sort the column headers in the matrix table in Power BI.
I hope you found this tutorial helpful. If you have any queries, mention them in the comments section below.
You may like the following tutorials:

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.