I built a client a sales matrix with products in the rows and months across the top. The numbers were right, but the months read Apr, Aug, Dec, Feb. The client’s first question was how to sort columns in the Power BI matrix so January came first, and the second was how to show the newest year on the left.
A matrix sorts rows and column headers in different ways, which is why this trips people up. In this tutorial, I’ll show you how to sort the rows by any value, how to put column headers in calendar, reverse or custom order, and how to fix the errors you’ll hit along the way.
Quick answer: To sort the rows, select the matrix, open More options (…) > Sort by, pick a field, then choose Sort descending or Sort ascending. Column headers can’t be sorted from the visual. Instead, select the column field in the Data pane and use Column tools > Sort by column with a numeric helper column, such as a month number.
How sorting works in a Power BI matrix
A matrix has two directions, and Power BI treats them differently. If you’re new to this visual, start with how to create a matrix visual in Power BI. Here’s what you can sort and where:
| What you want to sort | Where to do it | Example |
|---|---|---|
| Rows by a value or total | More options (…) > Sort by | Products by total revenue, highest first |
| Rows alphabetically | More options (…) > Sort by > row field | Products A to Z |
| Column headers in a logical order | Column tools > Sort by column | Jan to Dec instead of Apr, Aug, Dec |
| Column headers in reverse order | Column tools > Sort by column (negative helper) | 2026 before 2025 |
| Value columns (measures) | Drag them in the Values well | Revenue before Units |
The key thing to remember: the Sort by menu on the visual only lists the row field and the values. The field in Columns isn’t in that menu, so its order always comes from the data model.
For this tutorial, I’m using a sales table with 600 orders from 2025 and 2026: Product in Rows, Month in Columns and Sum of Revenue in Values. Month is a text column with values like Jan and Feb.

That’s the problem in one picture. Power BI sorts a text column alphabetically unless you tell it otherwise.
Sort matrix rows by a value (highest to lowest)
Let’s start with the rows, because that’s the easy part. I want the products with the most revenue at the top.
- Select the matrix on the report canvas.
- Select More options (…) in the visual’s header.
- Hover over Sort by and choose Sum of Revenue.
- Open More options again and choose Sort descending (highest first) or Sort ascending (lowest first).

Notice what’s in that submenu: Product and Sum of Revenue. Month isn’t there, even though it’s on the visual. That’s the limitation I mentioned above.
When you pick a number field, Power BI sorts it descending by default. A small arrow appears under the column you’re sorting by, here the Total column.

You can also click a value column header in the matrix to sort by it, and click again to flip the direction. If you need to rank rows by a calculation that isn’t on the visual, see how to sort by a measure in Power BI.
Sort matrix rows alphabetically
To put the rows in A to Z order, open More options > Sort by and pick the row field, Product in my case. Then choose Sort ascending for A to Z or Sort descending for Z to A.
If you have several fields in Rows, the sort applies within each level. Categories are sorted, and the products inside each category are sorted too.
Need to sort by two columns at once, such as Region and then Revenue? A matrix sorts by one field at a time. A table visual lets you hold Shift and click a second header to add it to the sort. See how to create a table visual in Power BI if you want to switch.
Sort column headers in calendar order (Jan to Dec)
Since the column field isn’t in the visual’s Sort by menu, you fix its order in the data model. You give Power BI a numeric column that defines the order, then tell it to sort the text column by that number.
Step 1: Add a month number column
Select the Sales table in the Data pane, then select Column tools (or Table tools) > New column and enter:
Month Number = MONTH(Sales[Order Date])
This returns 1 for January through 12 for December, taken from the order date.
Step 2: Sort the Month column by Month Number
- In the Data pane, select the Month column.
- On the Column tools tab, select Sort by column.
- Choose Month Number.

The matrix updates right away. The months now run from Jan to Dec, and the row sort by revenue stays in place.

The sort applies everywhere Month is used, in every visual and page. That’s why I usually put Month Number in a proper date table. Here’s how to create a date table in Power BI with month and year columns already sorted.
Sort column headers in descending order (newest year first)
Next, the client wanted years as columns with 2026 on the left. A Year column sorts ascending by default, and the matrix gives you no way to flip it. The trick is a helper column with negative numbers, so the newest year has the smallest value.
Year Sort = -YEAR(Sales[Order Date])
Then select the Year column and set Column tools > Sort by column > Year Sort. 2026 becomes -2026 and sorts before -2025.

Build the helper column from Order Date, not from Year itself. I first tried -Sales[Year] and got a circular dependency error. More on that in the troubleshooting section.
The same idea reverses months: Month Sort Desc = 13 - MONTH(Sales[Order Date]) puts December first.
Sort column headers in a custom order
Sometimes the order isn’t alphabetical or numeric at all. My client reports regions as East, Central, South, West, matching how their sales teams are organized. You can handle that with a SWITCH column:
Region Order =
SWITCH (
Sales[Region],
"East", 1,
"Central", 2,
"South", 3,
"West", 4,
99
)
Then sort Region by Region Order. Any region you didn’t list gets 99 and lands at the end, so a new region won’t break the visual.
If the order changes often, keep it in a small table instead. Use Home > Enter data to create a table with Region and Order columns, relate it to Sales on Region (many-to-one), sort its Region column by Order, and use that Region field in the matrix. Business users can then change the order without touching DAX.
Rearrange the value columns in a matrix
If you have several measures in the matrix, for example Revenue, Units and Margin, their order comes from the Values well, not from any sort setting. Drag the fields up or down in the Values well to rearrange the columns.
To show measures as rows instead, turn on Format visual > Values > Options > Switch values to rows. For a flat, Excel-like layout, see how to display a matrix in tabular format.
Want to hide one of those columns rather than move it? Here’s how to hide matrix column headers or columns. And if some columns end up too narrow after sorting, you can set a fixed column width in a matrix.
Troubleshooting matrix sorting
“A circular dependency was detected”
You’ll see this if the sort column is calculated from the column you’re sorting. My first attempt used Year Sort = -Sales[Year], and Power BI refused to sort Year by it:
![power bi sort by column circular dependency error Power BI error dialog: A circular dependency was detected: Sales[Year], Sales[Year Sort], Sales[Year]](https://www.enjoysharepoint.com/wp-content/uploads/2026/10/power-bi-sort-by-column-circular-dependency-error.png)
Calculate the helper column from another column instead, such as the order date, or create the helper column in Power Query. That’s why both helper columns in this tutorial use Sales[Order Date].
Other common problems
- An error that the sort column has more than one value: every month name must map to exactly one number. Check for mixed spellings like Sep and Sept, or a helper column built from the wrong field.
- Sort by column is grayed out: select a column in the Data pane, not a measure, and not the visual. Measures can’t have a sort-by column.
- The months are still alphabetical: you may have sorted a different Month column than the one in the visual, for example one in a date table versus one in the fact table.
- The row sort reset: adding or removing fields from the matrix can reset the visual’s sort. Set it again from More options.
- Totals look out of place after sorting: grand totals always stay at the bottom and right. If you don’t need them, turn off grand totals in the matrix.
These matrix tutorials pair well with sorting:
Frequently Asked Questions
Can I sort column headers in a Power BI matrix?
Not from the visual. Select the column field in the Data pane and use Column tools > Sort by column with a numeric helper column, as described in Microsoft’s Sort by column documentation.
Why are my months sorted alphabetically in Power BI?
Month names are text, so Power BI sorts them A to Z. Add a month number column and sort the month name column by it.
How do I sort a Power BI matrix by a column value?
Select the matrix, open More options (…) > Sort by, choose the value field, then pick Sort descending or Sort ascending. You can also click the value column’s header.
Can a Power BI matrix sort by multiple columns?
A matrix sorts by one field at a time. A table visual supports multi-column sorting with Shift+click on the headers.
How do I show the latest year first in matrix columns?
Create a helper column such as Year Sort = -YEAR(Sales[Order Date]) and sort the Year column by it.

I have worked with Microsoft technologies for more than 18 years, including SharePoint, Microsoft 365 and the Power Platform (Power Apps, Power Automate and Power BI), at companies like HP, TCS and KPIT. I started EnjoySharePoint in 2011 to share the solutions I build in real projects with readers in the United States, Canada, the United Kingdom, Australia, New Zealand and beyond. Microsoft has recognized this work with the Microsoft MVP award 13 times since 2014.