How to Change the Order of the X Axis in Power BI

Cody Schneider••7 min read

Getting your Power BI charts to sort correctly on the X axis can sometimes feel surprisingly tricky, but it's a quick fix once you know where to look. Power BI often defaults to alphabetical sorting, which scrambles your non-alphabetical data like months of the year or survey satisfaction levels. This article will walk you through the simple built-in sorting options and the powerful "Sort by Column" feature to get your visuals in perfect order.

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 Your Power BI Axis Isn't Sorting Correctly

If you've ever built a chart showing performance by month, you've likely seen this problem firsthand. The chart displays April, August, and December first, while February and January are somewhere in the middle. This happens because Power BI, by default, sorts text-based fields (like "January", "February") alphabetically.

The same logic applies to any custom category that has a natural, non-alphabetical order:

  • Days of the week: "Friday", "Monday", "Saturday", "Thursday"...
  • Satisfaction levels: "Neutral", "Satisfied", "Unsatisfied", "Very Satisfied"...
  • Development Stages: "Bronze", "Gold", "Platinum", "Silver"...

Power BI sees these as simple text values and logically arranges them from A to Z. To fix this, you need to tell Power BI that there's a hidden numerical order it should follow instead. For numbers on your X axis, this is straightforward - Power BI sorts them numerically from smallest to largest by default. The real challenge comes from telling it how to handle text categories that represent a specific sequence.

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 Basics: Sorting with Just a Click

Before diving into custom sorting, let's cover the quick and easy sorting options that are built directly into every Power BI visual. These are perfect when you just need to sort alphabetically, numerically, or by a measure you've added to the chart.

Imagine you have a simple bar chart showing 'Total Sales' by 'Product Category'.

Sorting the Axis Alphabetically

If you want to sort your product categories from A-Z or Z-A, the steps are simple.

  1. Click on the visual you want to sort to select it.
  2. In the top right corner of the visual, click the ellipsis (...) for more options.
  3. Hover over Sort axis.
  4. Select the name of your X-axis field (in this case, 'Product Category'). This tells Power BI you want to sort by the labels themselves.
  5. You can then go back to the "Sort axis" menu and toggle between Sort ascending (A-Z) and Sort descending (Z-A).

This will rearrange your bars to be in strict alphabetical order.

Sorting the Axis by a Value

More often, you'll want to sort your categories based on their performance - for instance, showing the product category with the highest sales first. This is just as easy.

  1. Select your visual. Find and click the ellipsis (...).
  2. Go to the Sort axis menu.
  3. This time, instead of selecting 'Product Category', select the measure you're charting (e.g., 'Total Sales').
  4. By default, this will likely sort descending - from the largest value to the smallest. If not, go back into the menu and choose Sort descending to see your top-performing categories first.

These two methods handle about half of all sorting needs. But what about when you need to sort months chronologically?

Custom Sorting: Taking Control with Sort by Column

This is where the real power lies. To get 'January', 'February', 'March'... in the correct sequence, you need to create a helper column that defines this order numerically (1, 2, 3...) and then use a feature called Sort by Column.

Let’s run through a full example of fixing a scrambled report of sales by month.

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

Step 1: Get into the Power Query Editor

The first step is to add a data column that Power BI can use for sorting. For this, we'll head over to the Power Query Editor.

  • On the "Home" tab in Power BI Desktop, click on Transform data. This will open the Power Query Editor, where you can shape and clean your raw data before it's loaded into the data model.

Step 2: Add a Numeric Helper Column

Once in Power Query, find the table containing your month names (e.g., 'Financials'). Now let's create a "Month Number" column. You have a couple of options for doing this.

Method A: Using "Conditional Column"

This method is quick and works well if you have a finite, permanent set of categories like months or weekdays.

  1. In the Power Query Editor, go to the Add Column tab.
  2. Click Conditional Column. A new window will pop up.
  3. Let's set up the logic. Name your new column something clear, like 'MonthNumber'.
  4. Set up a rule for each month:
  5. Click OK. You will now see a new 'MonthNumber' column in your table with the correct numeric sequence.

Method B: The Better Way - Merging Tables (Optional but Recommended)

While the conditional column is fast, a more scalable and professional approach is to create a small separate lookup table for your sort order and merge it. This keeps your sorting logic separate and easier to update.

  1. In Power Query, go to the Home tab and click Enter Data.
  2. Create a simple two-column table. Name the first column 'Month Name' and the second 'MonthNumber'.
  3. Manually enter the 12 months in the first column and their corresponding numbers (1-12) in the second.
  4. Name this table something like 'Month Sort' and click OK.
  5. Now, select your main data table (e.g., 'Financials'). Go to the Home tab and click Merge Queries.
  6. In the Merge window:
  7. A new column containing [Table] values will appear. Click the expand icon (two arrows) in the column header, deselect 'Month Name', and make sure 'MonthNumber' is checked. Click OK. Your numeric month number is now joined to your main data set.

Step 3: Close & Apply Changes

Whichever method you used, the final step in Power Query is to save your work. Go to the Home tab and click Close & Apply. This will load your new column into your Power BI data model.

Step 4: Use "Sort by Column"

This is the magic link. You've created the helper column, but now you have to explicitly tell Power BI to use it for sorting.

  1. Click on the Data view (the table icon) on the left-hand navigation pane in Power BI.
  2. Select the table you worked on. You will see all its columns.
  3. Find and click on the text column you want to sort - in our example, the Month Name column. Just click the column header to select the entire column.
  4. A menu tab called Column tools will appear in the ribbon at the top. Click on it.
  5. Find the Sort by Column button. Click it.
  6. From the dropdown list that appears, select your new helper column: MonthNumber.

It might not look like anything happened, but you have just re-wired how Power BI thinks about your 'Month Name' column on a fundamental level. From now on, anywhere that column is used in any chart, slider, or slicer, it will automatically sort chronologically based on 'MonthNumber'.

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 5: Check Your Visual

Go back to the Report view (the chart icon) on the left. Ta-da! Your bar chart is now sorted perfectly: January, February, March, and so on. If it hasn't updated, try clicking the ellipsis (...) on the visual, selecting 'Sort axis,' and re-selecting 'Month Name' on sort ascending - this will kickstart the new logic.

Final Thoughts

Learning how to reorder the X axis in Power BI is a milestone for any aspiring analyst. While its default alphabetic sorting makes sense from a technical standpoint, most business reports need custom chronological or categorical orders. The solution is creating a simple numeric "helper" column in your data model and then pointing your text column to it using the "Sort by Column" feature.

As you can see, Power BI offers extremely granular control, which is great for building detailed, custom reports. For teams in marketing and sales, however, this level of setup can sometimes get in the way of getting quick answers. For that, we created Graphed which uses AI to handle the tricky parts for you. Instead of setting up sort columns, you simply ask a question like "show me website sessions by month" and it not only builds the chart but also understands that "month" has a specific chronological order, taking care of the sorting automatically.

Related Articles