How to sort Power BI chart x axis by month & date?

Here’s a question from Emilio:

I loaded an Excel spreadsheet to my Power BI desktop app, and inserted a stacked chart visual. When looking at the x axis i see that the chart month axes (X) is sorted our in a wrong order – in my case alphabetically – which doesn’t make much sense. How can i arrange the axis labels in a chronological descending order. Any pointers here.

Order Power BI chart axis chronologically

To sort your Power BI visual x-axis by month name, follow the steps outlined in this tutorial:

  • In Power BI Desktop, hit the Insert button and then go ahead and pick the New Visual option.
  • Next, drag the required fields into the visual. In this example we will analyze the Course Revenues by calendar month, so we will drag the Month into the X Axis and Sum of Order Amount into the Y Axis of our visual.
  • Note: You can alternatively create a stacked chart by inserting more fields into your bar chart legend.
  • As you can see, our column chart is ordered by the Order amount – however in descending order.
  • Luckily we can fix this issue very easily: hover with your mouse over the upper right side of our visual and you will find the More Options button (3-dots).
  • Hit the More Options button and select Sort Axis.
  • The select your Date field (in our case Month).
  • Now, your months will be sorted in descending order which is not too helpful.
  • Hit again on More Options but now pick the Sort in Ascending Order option.
  • Your column chart should look as following:

Power BI chart not ordered according to day of the week

In our next example, we will look into sorting the Y axes in a stacked or cluster bar chart.

Assume that you have this visual showing sales amount by day of the week:

As can be observed the day of weeks are not order chronologically; for example: Sunday is the last day in the y axis.

Adding a day week column

The trick here is to sort our Day of Week column according to other column, which we will call Day of the Week Number.

  • In the right hand side Data pane, highlight your table.
  • Open the Data View.
  • From the Ribbon, hit the New Column Button.
  • Enter the following DAX formula and hit Enter:
Day of Week Number = WEEKDAY(Courses[Open Date])

You’ll see that a new column containing the week day number was created:

Ordering by day of the week chronologically

  • Now go back to the Report View.
  • In your Data tab highlight your y-axis field (in our case Day of Week).
  • From the Ribbon hit the Sort by Column button.
  • Pick the Day of Week Number field.
  • Your chart y-axis is chronologically arranged: