How to Sort Date in Power BI Graph
It’s one of the most common frustrations in Power BI: you build a beautiful line chart to show sales by month, but the X-axis is completely out of order. Instead of seeing a neat progression from January to December, your graph displays April, August, December, February… What’s going on? This article will walk you through exactly why this happens and provide a clear, step-by-step fix that will become a cornerstone of your Power BI skills.
Why Won't Power BI Sort My Dates Correctly?
The short answer is that Power BI, by default, sorts text fields alphabetically. When you pull a column like "Month Name" into your visual's axis, Power BI sees it as simple text - "January," "February," "March." It doesn't inherently understand that "February" comes after "January." Instead, it applies standard alphabetical logic, resulting in an A-D-F order: August, April, December, February...
This same problem occurs with days of the week ("Friday," "Monday," "Saturday") and custom date formats like "Jan 23," "Feb 23," which it might also interpret alphabetically if the underlying data type isn't set up correctly.
To fix this for good, you need to stop letting Power BI guess. You need to explicitly tell it how to sort your time-based text fields by giving them a numerical helper column. The best practice for achieving this involves creating a dedicated Date Table.
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.
The Foundation: Create a Proper Date Table
While you might be tempted to just add a quick column to your existing sales or marketing data, the most robust and scalable solution is to create a separate, dedicated table just for dates. This is a fundamental best practice in data modeling that will save you countless headaches down the road. A Date Table centralizes all of your time-based logic, simplifies powerful DAX time intelligence functions like YEAR-TO-DATE or SAMEPERIODLASTYEAR, and, critically for our purpose, provides the structure we need to solve sorting issues.
You can create a date table easily using DAX. In Power BI Desktop, navigate to the Data view (the little table icon on the left-hand pane), go to the Home tab in the ribbon, and click "New Table."
Option 1: The Quickest Method with CALENDARAUTO()
If you have date fields scattered throughout your data model (e.g., order dates, ship dates, publish dates), the CALENDARAUTO() function is the fastest way to get started. It automatically scans your entire model, finds the earliest and latest dates, and creates a continuous date table that covers that entire span.
In the DAX formula bar for your new table, enter:
Dates = CALENDARAUTO()Hit Enter, and a single column named "Date" containing every date in your data's range will appear.
Option 2: Setting a Specific Range with CALENDAR()
If you prefer to have more control and define a specific range, you can use the CALENDAR() function. This is useful if you want your table to run from, say, the start of 2022 to the end of 2025, regardless of the dates in your existing data.
The syntax is CALENDAR(StartDate, EndDate). Here’s a practical example:
Dates = CALENDAR(DATE(2022, 1, 1), DATE(2025, 12, 31))Adding the Helper Columns for Sorting
With your base date table created (a single column of continuous dates), it's time to add the other columns we’ll need for our visuals and, most importantly, for sorting. While still in the Dates table, click "New column" in the "Table tools" ribbon for each of the following formulas.
1. Year
This column will extract the four-digit year from the date.
Year = YEAR([Date])2. Month Number (The Sort Key)
This is crucial. The month number (1 for January, 2 for February, etc.) will be the column we use to tell Power BI the correct chronological order of the month names.
Month Number = MONTH([Date])3. Month Name
This is the column you’ll actually use on your chart's axis. The "mmmm" format code returns the full month name.
Month Name = FORMAT([Date], "mmmm")4. Day of Week Number (The Other Sort Key)
Just like with months, we need a numeric key for sorting days of the week. The WEEKDAY function handles this. We use the second parameter, 2, to set Monday as 1 and Sunday as 7, which is a common business standard.
Day Number = WEEKDAY([Date], 2)5. Day of Week Name
This will be the text column for our visual. The "dddd" format code gives the full day name.
Day Name = FORMAT([Date], "dddd")After adding these columns, your date table should look something like this:
- Date: 1/1/2024
- Year: 2024
- Month Number: 1
- Month Name: January
- Day Number: 1
- Day Name: Monday
The Magic Step: The "Sort by Column" Feature
Now we get to the core of the solution. You need to assign the sorting logic to your text-based columns inside the data model itself. This is not something you do inside the chart visual settings, it's a permanent rule you establish for the data column.
Here’s how to do it:
- Stay in the Data view.
- Make sure you have your new 'Dates' table selected in the Fields pane on the right.
- Click on the header of the column you want to fix the sort order for. Let’s start with Month Name. A gray highlight will confirm it's selected.
- In the top ribbon, a new "Column tools" tab will appear. Find the icon labeled "Sort by column."
- Click this icon. A dropdown menu will appear listing all the other columns in your Dates table.
- Select Month Number from the list.
That’s it! You’ve just told Power BI that whenever it sees the Month Name column, it should use the Month Number column's values to determine the sort order. Power BI will churn for a moment, and then your command is set.
Repeat this process for your Day Name column:
- Select the Day Name column.
- Click "Sort by column" in the ribbon.
- Choose Day Number from the dropdown list.
Putting It All Together in Your Visual
Almost there. There are two final, crucial steps to make this work.
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.
1. Create the Table Relationship
Your beautiful new Dates table won't do anything if it's not connected to your data. Go to the Model view (the third icon on the left, looks like three connected boxes). Find your Dates table and your main data table (e.g., 'Sales Orders'). Drag the Date column from your Dates table and drop it directly onto the date column in your other table (e.g., OrderDate). A line will appear, indicating a one-to-many relationship.
2. Build and Sort Your Graph
Now, go back to the Report View. Create a chart, perhaps a line chart.
- From your 'Sales Orders' table, drag your Sales Amount to the Y-axis.
- Crucially, from your new Dates table, drag Month Name to the X-axis. Do not use the month from your original data table.
Your chart should now magically display with the months in the correct chronological order: January, February, March, and so on. If it's backward (showing December to January), click the three-dot menu (...) on your visual, go to Sort axis, and ensure it's set to Sort ascending.
Final Thoughts
What initially seems like a confusing bug in Power BI is actually a feature that gives developers granular control over data presentation. By creating a dedicated date table and using the "Sort by column" function, you establish clear rules that tell your visualizations precisely how to handle chronological data, moving beyond simple alphabetical sorting.
Mastering these steps eliminates one of the most common reporting roadblocks and saves countless hours of frustration. As you're working through these steps, though, you can see how even seemingly simple reporting tasks involve a lot of hidden setup and configuration just to get the basics right. We built Graphed to remove this tedious busywork for marketing and sales teams. Instead of manually creating date tables and setting sort rules, you can just ask, "Show me a line chart of sales revenue by month over the past year," and the platform builds a live-updating, correctly sorted dashboard for you in seconds.
Related Articles
Facebook Ads For Personal Trainers: The Complete 2026 Strategy Guide
Learn how to effectively use Facebook ads for personal trainers in 2026. This comprehensive guide covers targeting strategies, ad creative, budgeting, and optimization techniques to help you grow your training business.
Facebook Ads for HVAC Companies: The Complete 2026 Strategy Guide
Learn how to run high-converting Facebook ads for HVAC companies in 2026. This guide covers targeting, creative strategies, and proven campaigns that drive real leads.
Facebook Ads for Florists: The Complete 2026 Strategy Guide
Learn proven Facebook advertising strategies for florists in 2026. Target the right audience, create compelling visuals, and optimize your ad budget for maximum ROI.