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
gjayne84
Helper I
Helper I

Sorting months in chronological order

Hi everyone

 

I know this question has been asked a lot but I'm really struggling getting a line cgart to displa the months in chronological order rather than alphabetical.  I have followed the instructions here to create a MonthNo column.  However, I can't get the column to display the month numbers with a leading 0 so the sort order is incorrect as shown below:

 

Capture.PNG

 

If anyone could give me any pointers, or whether there is a better way to achieve what I need, I would be really grateful.

 

Many thanks in advance for your help.

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@gjayne84 Please try to change the datatype of MonthNo field to Numeric. Then use "Sort by Column" option to sort the Month by MonthNo (Select Month Field and then use "Sort by Column" option to use MonthNo as sort order)




Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

4 REPLIES 4
jjupiter100
New Member

I think I have a much simpler answer.  The 2 main issues are the first letters of each month of the year are not in alphabetical order, so Excel always wants to put April first instead of January.  And if you try to give each month a number, October, November, and December present problems because 10, 11, and 12 get put before 1 (which would be January).

So, however you're going to label your months (typically January = 1, February = 2 and so on), make October = 91 (because September would have equaled 9), make November = 92 and December = 93. 

This gets your pivot table sorted correctly and when you go to make your graph, you can just rename each of those fields to be whatever you want.  And most importantly, they'll stay in the same order you want them.

PattemManohar
Community Champion
Community Champion

@gjayne84 Please try to change the datatype of MonthNo field to Numeric. Then use "Sort by Column" option to sort the Month by MonthNo (Select Month Field and then use "Sort by Column" option to use MonthNo as sort order)




Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Stachu
Community Champion
Community Champion

you need to sort Month by MonthNo with 'Sort By Column' in Modelling ribbon (you may need to remove and add the Month in the visual to remove other sorting)

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column#sort-using-the-sort-by-column-butto...



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Hi @gjayne84.

 

You can add a 0 before the number from 1 to 9 to get the correct order doing a simple transformation in Query Editor. 

 

Text.PadStart([MonthNo], 2, "0")

 

Regards,

 

Marcos Pérez

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.