How to Manually Sort Columns in Power BI
Your Power BI chart looks fantastic - the colors are perfect, the data is accurate, and the title is spot-on. There’s just one problem: it’s sorted alphabetically. Instead of a neat "January, February, March," you’re looking at a nonsensical "April, August, December." This common frustration happens because Power BI sees text and defaults to sorting it from A-Z. This article will show you exactly how to fix this by creating a custom sort order for any column in your report.
Why Your Columns Are in the Wrong Order
By default, Power BI is designed to sort text data alphabetically and numeric data sequentially. It doesn't inherently understand that "January" should come before "February" or that "High Priority" should be listed before "Medium Priority." When it sees a column containing text like month names, days of the week, or custom category labels ("Standard," "Premium," "Enterprise"), it simply applies an A-Z sort.
This leads to visuals that are hard to interpret, like this bar chart for monthly sales:
*(Instead of January -> December, you see: April, August, December, February, January...))
This isn't a bug, it's simply how the software handles data types. To get the chronological or logical order you need, you have to explicitly tell Power BI how to sort your text column. The key is to create a second, "helper" column that contains a numeric value representing your desired sort order (e.g., 1 for January, 2 for February). Once that's done, you can use Power BI's "Sort by Column" feature to link your text-based column to your new numeric one.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Method 1: Using Power Query for a Permanent Sort
Power Query is Power BI's tool for importing and transforming data. Creating your sort column here is often the best practice because it embeds the logic directly into your data model. Any changes you make in Power Query are applied every time your data is refreshed, making it a robust, set-it-and-forget-it solution.
Let's walk through creating a month number column for a "Month Name" column.
Step 1: Open the Power Query Editor
First, you need to access the Power Query Editor. From the main Power BI Desktop window, go to the Home tab on the ribbon and click on the Transform data button. This will launch a new window where you can build your custom logic.
Step 2: Add a Conditional Column
Once in the Power Query Editor, find your table in the left pane and select it.
- Navigate to the Add Column tab in the top ribbon.
- Click on Conditional Column. This will open a user-friendly wizard for building if-then logic without writing any code.
Step 3: Configure the Sorting Logic
The "Add Conditional Column" window is where you'll define the correct order. Here's how to fill it out:
- New column name: Give your new column a clear name, like "Month Number" or "MonthSortOrder."
- The Logic: You'll create a rule for each month.
- Else: It's good practice to set a default value in the "Else" field at the bottom. You can enter something like 99 or 0 to easily spot any data that doesn't fit your rules later on.
Your finished setup should look something like this:
Step 4: Set the Data Type and Apply Changes
After you click "OK," a new "Month Number" column will appear in your table. Power Query might assign it an "Any" data type. To ensure it sorts correctly, click the icon next to the column name (e.g., "ABC 123") and set the data type to Whole Number.
Finally, go to the Home tab in the Power Query ribbon and click Close & Apply. This will save your changes and load the newly structured table back into your data model.
Method 2: Using DAX for a Flexible Sort
Another way to achieve this is by using DAX, Power BI's formula language. This method is great if you can't edit the data source in Power Query or if you prefer a more formula-driven approach. It achieves the same result, but the calculation lives inside your data model rather than in the Power Query shaping process.
Step 1: Go to the Data View
In the main Power BI window, click on the Data icon on the left-hand navigation pane (it looks like a small table).
Step 2: Create a New Calculated Column
Select the table you want to modify from the "Data" pane on the right. With the table selected, you'll see a Table tools tab appear in the ribbon. Click New column.
A formula bar will appear above your data table, ready for you to enter your DAX expression.
Step 3: Write the SWITCH Function
While you could use a series of long, nested IF statements, the SWITCH function is a much cleaner and more efficient way to build this logic in DAX. Enter the following formula into the formula bar, replacing 'YourTable'[MonthName] with the actual name of your table and month column.
Month Number =
SWITCH(
TRUE(),
'YourTable'[MonthName] = "January", 1,
'YourTable'[MonthName] = "February", 2,
'YourTable'[MonthName] = "March", 3,
'YourTable'[MonthName] = "April", 4,
'YourTable'[MonthName] = "May", 5,
'YourTable'[MonthName] = "June", 6,
'YourTable'[MonthName] = "July", 7,
'YourTable'[MonthName] = "August", 8,
'YourTable'[MonthName] = "September", 9,
'YourTable'[MonthName] = "October", 10,
'YourTable'[MonthName] = "November", 11,
'YourTable'[MonthName] = "December", 12,
0
)Press Enter. Power BI will then evaluate this formula for every row in your table and populate the new "Month Number" column accordingly.
Applying Your Custom Sort: The "Sort by Column" Feature
Creating the helper column is only half the battle. Now you need to tell Power BI to use it as the source for sorting your month name column. This is the most important step and the one that's easiest to forget.
Step 1: Select the Column You Want to Sort
Still in the Data View, click on the column header of the original text column you want to sort. In our example, you would click on the header for the "MonthName" column. Do not select the new numeric column you just created.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Step 2: Choose "Sort by Column"
With the "MonthName" column selected, a Column tools tab appears in the ribbon. Find and click the Sort by Column button.
Step 3: Select Your New Numeric Column
A dropdown menu will appear. From this list, choose the helper column you created — "Month Number". Power BI might take a moment to process, but behind the scenes, it's creating a relationship that tells it "whenever you display 'MonthName,' use the order from 'Month Number.'"
Step 4: Check Your Visuals
Navigate back to the Report View (the top icon on the left pane). Your chart should now be correctly sorted! "January" will appear first, followed by "February," and so on. Any new visual you create with the "MonthName" field will now automatically use this custom sort order.
More Than Just Months: Other Common Scenarios
This powerful technique isn't limited to dates. You can use it to logically organize any non-alphabetical data. Here are a few other practical examples:
- Days of the Week: Sort your data from "Monday" (1) to "Sunday" (7) instead of the default alphabetical order (Friday, Monday, Saturday...).
- Survey Responses: Organize feedback logically, such as "Strongly Agree" (1), "Agree" (2), "Neutral" (3), "Disagree" (4), "Strongly Disagree" (5).
- Product Tiers: Display subscription or product levels in their intended order: "Bronze" (1), "Silver" (2), "Gold" (3), "Platinum" (4).
- Priority Levels: Show project tasks or support tickets in order of importance: "Urgent" (1), "High" (2), "Medium" (3), "Low" (4).
Final Thoughts
Getting your Power BI charts in the right order just takes a few steps. By creating a numeric helper column using either Power Query or DAX and then applying the "Sort by Column" function, you can teach Power BI to organize your data exactly how you need it, making your reports far more intuitive and professional.
Instead of manually creating sorting columns and setting up this logic for all your reports, we built Graphed to handle the busywork for you. Our platform uses AI to understand your data's context. When you ask to "see our monthly sales," it automatically recognizes that you want a chronological order and creates a perfectly sorted chart in seconds. We connect to all your marketing and sales data sources, allowing you to build real-time dashboards with plain English, free from formula headaches.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.