How to Sort X Axis by Month in Power BI

Cody Schneider8 min read

One of the first frustrating roadblocks everyone hits in Power BI is seeing your months sorted alphabetically on a chart's X-axis. You build a beautiful visual to track sales, only to see your data presented as April, August, December, February - a completely useless order for spotting trends. This isn't a bug, Power BI is just sorting text the way it's told, alphabetically. This guide will walk you through the proper way to fix this common issue by creating a calendar table and telling Power BI exactly how to sort your months chronologically.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Why Does Power BI Sort Months Alphabetically by Default?

When you load data into Power BI that includes a date, you might add a "Month Name" column by using a function like FORMAT([Date], "MMMM"). While this correctly produces text like "January," "February," and "March," Power BI sees these values as simple text strings. A computer has no inherent understanding that "February" comes after "January." So, when it's time to plot them on an axis, Power BI falls back on its default sorting rule for text: A to Z.

The result is a chart that looks something like this:

Total Sales

  • April: $12,000
  • August: $18,000
  • December: $25,000
  • February: $9,000
  • January: $8,500
  • ...and so on.

It's impossible to see your performance across the first quarter or analyze seasonal trends when your timeline is scrambled. The solution is to provide Power BI with more context. We need to associate the text "January" with the number 1, "February" with 2, and so on. The best-practice way to achieve this is with a dedicated calendar table.

The Best Practice: Create a Calendar Table

Instead of cramming more columns into your existing data tables (like your sales data), the gold standard in Power BI data modeling is to use a separate, dedicated calendar table (also called a date table). This table contains a contiguous list of all dates you might need and includes useful columns like Year, Month Name, Month Number, Day of Week, and Quarter.

Creating this table gives you a single source of truth for all time-based analysis in your report. It's more efficient, scalable, and keeps your data model clean. Here are two straightforward methods to create 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: Creating a Calendar Table with DAX

DAX (Data Analysis Expressions) is Power BI's formula language. With just a few simple formulas, you can generate a robust calendar table in seconds. A huge benefit of this method is that the table will automatically update itself if your primary dataset expands to include new dates.

Step 1: Create a New Table

First, navigate to the Data view in Power BI (the second icon on the left sidebar). Then, in the top ribbon, go to the Modeling tab and click on the New table icon.

Step 2: Use a Calendar Function

A formula bar will appear above your data. Here, you'll use a DAX function to generate your list of dates. You have two excellent options:

  • CALENDARAUTO(): This is usually the easiest choice. It automatically scans your entire data model, finds the earliest and latest dates, and creates a full calendar table to cover that entire range.
  • CALENDAR(StartDate, EndDate): This function gives you more control, letting you specify the exact start and end dates for your table.

For most cases, CALENDARAUTO() is perfect. In the formula bar, type:

Dates = CALENDARAUTO()

Hit Enter. You'll now have a new table named "Dates" with a single column containing a unique date for every day between the minimum and maximum dates in your model.

Step 3: Add Columns for Month Name and Month Number

With our base table created, we just need to add the helper columns for sorting. We will add a column for the Month Name (the text) and Month Number (the numeric identifier).

With your new 'Dates' table selected in the Data view, click New column from the Modeling ribbon. Add the following columns one by one, hitting Enter after each formula:

Month Name (e.g., "January", "February"):

Month Name = FORMAT([Date], "MMMM")

Month Number (e.g., 1, 2, 3):

Month Number = MONTH([Date])

You can also create other useful columns while you're at it, like:

Short Month Name (e.g., "Jan", "Feb"):

Month Short = FORMAT([Date], "MMM")

Year:

Year = YEAR([Date])

When you're finished, your 'Dates' table will have a list of dates along with all the columns needed for correct sorting and analysis.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Method 2: Creating a Calendar Table with Power Query

If you prefer a more visual, step-by-step approach, you can build your calendar table in the Power Query Editor. This is the "back end" of Power BI where you perform data transformation.

Step 1: Open Power Query and Create a Blank Query

From the Home ribbon, click on Transform data to open the Power Query Editor. In the new window, click on New Source > Blank Query.

Step 2: Generate a List of Dates

Select your newly created Query1. You'll see a formula bar at the top starting with = Source. While there are many ways to do this, a simple method is to find the start and end dates from your existing data.

For simplicity, let's create a list from a defined start and end date. You can copy and paste this M code into the formula bar. Just adjust the StartDate and EndDate as needed.

let
    StartDate = #date(2023, 1, 1),
    EndDate = #date(2024, 12, 31),
    NumberOfDays = Duration.Days(EndDate - StartDate) + 1,
    DatesList = List.Dates(StartDate, NumberOfDays, #duration(1, 0, 0, 0)),
    TableFromList = Table.FromList(DatesList, Splitter.SplitByNothing(), {"Date"}),
    ChangedType = Table.TransformColumnTypes(TableFromList, {{"Date", type date}})
in
    ChangedType

After pasting this, you will have a single column named "Date" with all the dates in your specified range. Rename your query something descriptive, like Calendar Table.

Step 3: Add Date Columns

Now, just like in the DAX method, we'll add helper columns. Power Query makes this incredibly easy with its user interface.

  1. Select the "Date" column.
  2. Go to the Add Column tab in the ribbon.
  3. Click the Date dropdown. You will see options for Year, Month, Quarter, etc.
  4. Go to Month > Month. This will add a "Month" column with numbers 1-12. Rename this column to Month Number.
  5. Select the "Date" column again.
  6. Go to Add Column > Date > Month > Name of Month. This will add a "Month Name" column with the text.

Once you are done, click Close & Apply on the Home ribbon to load your new table into the Power BI model.

Connecting the Dots: Relationships and Sorting

You have a calendar table, and your main data has its own date column. Now we just need to connect them and tell Power BI how to use them together.

Step 1: Create a Relationship

Navigate to the Model view (the third icon on the left sidebar). You'll see your tables represented as boxes.

Find your new Calendar Table and your main data table (e.g., Sales). Click and drag the Date column from your Calendar Table and drop it directly onto the date column in your Sales table (e.g., OrderDate). A line will appear between the two, representing a relationship. This tells Power BI that any filter applied to the Calendar Table should also apply to the Sales 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.

Step 2: The Final Fix - Use "Sort by Column"

This is the magic step that ties it all together. You need to explicitly tell Power BI that the Month Name column should not be sorted alphabetically but by the Month Number column.

  1. Go back to the Data view.
  2. Select your Calendar Table from the Fields pane on the right.
  3. Click on the header of the Month Name column to highlight it. The Column tools tab will appear in the top ribbon.
  4. In the ribbon, click the Sort by column button.
  5. A dropdown menu will appear. Select Month Number.

Power BI now understands the correct chronological order for your month names. The change is immediate, though you may not see anything happen in the Data view itself.

Step 3: Update Your Visual

Now, go to the Report view and find your chart.

First, make sure you are using the correct fields. In the chart’s properties, drag the Month Name from your new Calendar Table to the X-axis. Do not use the month from your original data table.

Then, click the three dots (...) at the top right of your visual, go to Sort axis, and ensure it is sorted by Month Name and in Ascending order.

Voila! Your X-axis should now proudly display: January, February, March, April... a trend-spotter's dream.

Final Thoughts

Sorting months chronologically is a fundamental step in building meaningful time-series reports in Power BI. While it appears complicated at first, the process of creating a calendar table and using the "Sort by column" feature is a core skill that separates good reports from great ones. It gives you precise control over your data model and unlocks more powerful analysis.

Manually setting up calendar tables and sorting rules in Power BI is a common task, but it’s exactly the kind of repetitive work that can slow you down. At Graphed you can handle this technical setup automatically. You don't have to build date tables or define sort columns, our AI just understands that months have a chronological order. When you connect your data and ask, "Show me my revenue by month for last year," it instantly builds the correct chart, properly sorted, so you can focus on finding insights, not wrestling with data modeling.

Related Articles