Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sorting by Month

Hi all,

 

I'm having a bit of a headache when trying to sort a graph by month. Normally it's no problem but this time my months are located in different years (some in 2017 and some in 2018). When I have the graph at year level I have no issues, but when I drill down in every year at the same time, the months are sorted wrong.

 

Does anyone know how to fix this? I have a regular database from excel and can change data type and create extra columns.

 

Thanks in advance!

5 REPLIES 5
Anonymous
Not applicable

You could create a column where you concatenate both year and month like January 2017, February 2017, and so on. Then put an index column. From there you can sort your Month by the index column, which is basically the sequence of the concatenated column of Month and Year. Or you could create a parameter table of months from January to December with index 1 to 12, then connect the months in your data to that table, which is sorted by the index. You could then use the months in the parameter table in your chart. 

Anonymous
Not applicable

Hi @Anonymous

 

This won't work for me, as I have dublicates in my date column and Power BI will not allow me to sort by index, as there are multiple index values for the same date.. 

But thanks for the input!

Create a column for a month name using something like "FORMAT([Date],"mmm")" to get the month name. Create another one column that is MONTH([Date]). Now sort the month name field by the month number field. Use the month name field in your visual.

 

That being said, if you are working with a real Date or Date/Time field and using the built-in hierarchy, it should sort the months correctly.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

Sample data would help to recreate and it would also help to know how the months are being sorted, alphabetically? Generally if they are being sorted alphabetically you need to create a numeric month field and set your Sort By field to this numeric month column.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

year.pngmonths.png

 

Hi Greg - my graphs look like this, where the second one is where I drill into both years at the same time (January, March, April is 2019, rest is 2018). So it seems that the months are being sorted as if all the data were in the same year.

 

A sample of the date data is below:

 

Dates.png

 

Hope you can help 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.