How to Change Column Order in Matrix Power BI
Building a matrix visual in Power BI should be simple, but getting your columns to line up in the right order can be frustrating. You might build the perfect report, only to find that your months are sorted alphabetically (April, August, December...) or your product stages are in an illogical sequence. Unlike a simple table in Excel, you can’t just drag and drop the matrix columns into place.
This tutorial will fix that. We'll walk you through several clear, practical methods to take control of your column order in any Power BI matrix, from a simple fix to a more advanced data shaping technique.
Why Can't You Just Drag and Drop Columns in a Power BI Matrix?
Before jumping into the solutions, it helps to understand why Power BI behaves this way. A Power BI matrix is not the same as a spreadsheet grid. When you add a field to the "Columns" area of the matrix visual, Power BI looks at all the unique values in that field and automatically creates a column for each one. By default, it sorts these values A-to-Z or numerically in ascending order.
For example, if you drag a "Month Name" field into the Columns well, Power BI sees "January," "February," "March," etc. It doesn’t understand that these have a specific chronological order, it just sees them as text and sorts them alphabetically. The same goes for any non-numeric category like "Low," "Medium," and "High" priority, which would sort to "High," "Low," "Medium." The key takeaway is simple: to control the column order, you need to tell Power BI how to sort them by giving them an underlying numeric sequence.
Let's look at the best ways to do this.
Method 1: Use 'Sort by Column' (The Standard Fix)
The "Sort by Column" feature is the go-to solution for this problem and is a fundamental skill for any Power BI user. We'll use the common example of ordering month names correctly, but the principle applies to any column.
The core idea is to have two columns in your data model: one with the text you want to display (e.g., "January") and another with the associated number you want to sort by (e.g., 1).
Step 1: Create a Numeric Sorting Column
First, you need a column that assigns a numeric value to each text value. If you have a good Date table in your model (which is highly recommended!), you likely already have a MonthNumberOfYear column. If your dataset is simpler and you don't have one, you can easily create one using a calculated column with DAX.
Navigate to the Data view in Power BI, select the table containing your month names, and click "New column" from the ribbon. Then, enter a DAX formula like this:
Month Number = SWITCH( 'YourTable'[Month Name], "January", 1, "February", 2, "March", 3, "April", 4, "May", 5, "June", 6, "July", 7, "August", 8, "September", 9, "October", 10, "November", 11, "December", 12 )
Be sure to replace 'YourTable'[Month Name] with the actual column you want to sort. When you press Enter, a new "Month Number" column will be added to your table.
Step 2: Apply the 'Sort by Column' Feature
Now that you have your sorting key, you can tell Power BI to use it. Follow these steps:
- In the Data view, make sure you've selected the text column you want to sort, not the numeric one. In this case, click on the "Month Name" column header.
- A new "Column tools" tab will appear in the top ribbon.
- Click the Sort by Column button.
- A dropdown list will appear containing all other columns in your table. Select the numeric sorting column you prepared in the previous step (e.g., "Month Number").
That's it! Power BI now knows that whenever it displays the "Month Name" column, it should order it according to the "Month Number" column. When you go back to your report, your matrix visual should automatically update with the correct chronological order: January, February, March, and so on.
Troubleshooting Tip
If your matrix columns don't immediately rearrange, don't worry. Click the three dots (...) at the top-right corner of your matrix visual, go to "Sort by," and select your column name (e.g., "Month Name"). Then, ensure your sort direction is set to "Sort ascending." This will force the visual to re-evaluate sorting based on the new rule you defined.
Method 2: Using Power Query to Add a Sort Order Column
Creating your sorting logic directly in Power Query is often a cleaner and more performant alternative to using DAX calculated columns. This method keeps all your data transformations in one place and happens before the data is even loaded into the model.
Let's tackle a different example: sorting survey responses like "Poor," "Fair," "Good," and "Excellent," which would normally sort alphabetically.
Step 1: Create the Custom Order in Power Query
We'll add a new column in Power Query that assigns a number to each response text.
- Open the Power Query Editor by clicking "Transform data" on the Home ribbon.
- Select the query (your table) that contains the "Response" column.
- Go to the Add Column tab and click on Conditional Column.
- A dialog box will pop up. This is where you'll build the logic without writing code:
You’ll now see a "Response Order" column in your table. Click "Close & Apply" on the Home ribbon to load your changes into the Power BI model.
Step 2: Apply the Sort in Power BI
From here, the steps are identical to Method 1:
- Go to the Data view.
- Select the Response column (the text one).
- In the "Column tools" ribbon, click Sort by Column.
- Choose your new Response Order column.
Your matrix columns will now display in the logical order of Poor, Fair, Good, and Excellent.
Method 3: Restructuring Your Data Using Unpivot
Sometimes the root of the sorting problem isn't the values - it's the entire structure of your data. This often happens with data exported from older systems or managed in spreadsheets, where values that should be in a single column are spread out across multiple columns.
Imagine your data looks like this:
- Column 1: Product Name
- Column 2: Q1 Sales
- Column 3: Q2 Sales
- Column 4: Q3 Sales
- Column 5: Q4 Sales
To analyze this in a Power BI matrix, you might be tempted to drag each of the "Qx Sales" measures into the values well, but this is inflexible and difficult to manage. The best practice is to "unpivot" this data so you have three columns instead: Product Name, Quarter, and Sales.
How to Unpivot in Power Query:
- Open the Power Query Editor ("Transform data").
- Select the query containing your wide data.
- Select the columns you want to unpivot. In our example, click the heading for "Q1 Sales," then hold down the Shift key and click the "Q4 Sales" column to select all four quarter columns.
- Go to the Transform tab in the ribbon.
- Click on the dropdown next to Unpivot Columns and choose "Unpivot Columns" (or right-click the selected column headers and choose it from the context menu).
- Your selected columns will be replaced with two new ones, likely named "Attribute" and "Value."
- Rename "Attribute" to "Quarter" and "Value" to "Sales." Now your data is in a much cleaner, more usable format.
After unpivoting, you can apply Method 1 or 2. Just create a new custom column that gives a numeric order to your new "Quarter" column (Q1 = 1, Q2 = 2, etc.) and then use "Sort by Column" to organize your matrix correctly every time.
Common Pitfalls and Troubleshooting
- The "Sort by Column" icon is grayed out. You are likely selecting a measure or a calculated column created with complex DAX that depends on other calculations. The "Sort by Column" feature works on physical columns in your data table or simple calculated columns.
- The order still won't update in the report. As mentioned earlier, try clicking the three dots on the visual itself to set the sort column and direction manually. This often forces the matrix to respect the new settings.
- You get a "circular dependency" error. This typically happens when you create Sort Column A based on Data Column B, and Data Column B's calculation somehow relies on Sort Column A. Ensure your sorting column is standalone and built from a static definition like a SWITCH statement or by adding it in Power Query.
Final Thoughts
Customizing column order in a Power BI matrix is a classic example of needing to understand your data's structure rather than just the visual settings. While Power BI's default alphabetical sort is predictable, using a hidden numeric ordering column is the key that unlocks full control over your presentation and makes your reports intuitive and professional.
Creating reports in BI tools means mastering many small but important details just like this. At our company, we saw how often teams get bogged down in these technical hurdles. That's why we built Graphed. We wanted to create an experience where you can get insights from your marketing and sales data without ever getting stuck. Instead of building matrices, merging queries, and setting sort columns, you can simply ask, "show me our sales revenue by month for last quarter as a bar chart," and get an instant, real-time visualization, letting you go straight from question to insight.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?