Sorting Month Names Chronologically in Microsoft Power BI Reports
Often times, in Power BI, you’re adding dates to your reports and would prefer to use the more formal month name rather than the month number. After all, it can give your reports a more polished look. Trouble is, Month Name fields are text fields, and therefore Power BI has no choice but to sort them alphabetically. I mean, who wouldn’t want their date sorted by April, then August, then December, then February, right? Well, there’s a trick that will let you sort dates the way they should be sorted, whether you’re using the month name or number.
If you would like to follow along with our How-to Video please click here
For the sake of the exercise, let’s create a date table in Power BI Desktop.
Go to Modeling, New Table
Replace “Table = “ with the following code to create a table called “Date”:
Date =
ADDCOLUMNS (
CALENDAR (DATE(2000,1,1), DATE(2025,12,31)),
“DateAsInteger”, FORMAT ( [Date], “YYYYMMDD” ),
“Year”, YEAR ( [Date] ),
“Monthnumber”, FORMAT ( [Date], “MM” ),
“YearMonthnumber”, FORMAT ( [Date], “YYYY/MM” ),
“YearMonthShort”, FORMAT ( [Date], “YYYY/mmm” ),
“MonthNameShort”, FORMAT ( [Date], “mmm” ),
“MonthNameLong”, FORMAT ( [Date], “mmmm” ),
“DayOfWeekNumber”, WEEKDAY ( [Date] ),
“DayOfWeek”, FORMAT ( [Date], “dddd” ),
“DayOfWeekShort”, FORMAT ( [Date], “ddd” ),
“Quarter”, “Q” & FORMAT ( [Date], “Q” ),
“YearQuarter”, FORMAT ( [Date], “YYYY” ) & “/Q” & FORMAT ( [Date], “Q” )
)
Now let’s create a simple table visualization.
And then drag the MonthNameLong field into the table.
We get the list of months, but they are listed alphabetically rather than chronologically.
We can change the way the table sorts, however. First, click on the MonthNameLong field in the Fields bar. Don’t check the box, simply select the field so it looks like it does here:
Then return to the Modeling tab, and you’ll see the “Sort By” button is no longer dim. Click it, and you’ll see that “MonthNameLong” is the currently selected “sort by” field:
Click “Monthnumber” instead, and voila!
It’s important to note that this change should be made in the Report viewer, not the Table, to ensure chronological sorting appears on the report.
Follow along these instructions with a helpful and short video
We hope you enjoy our collection of helpful how-to, tips and tricks, and demo videos