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 3-letter abbreviated months on Matrix

Hi there,

 

I have to show the first 3 letters of the months in order for my table to fit properly. I do not need years to be visible.
I already have a date hierarchy [FirstOfMonth], and created a 3 letter abbreviation calculated column [3LetterMonth]

 

When I add the calculated column it returns as a text and not date. When converting the [3LetterMonth] column to a Date data type I recieve an #ERROR. 

 

My formula for the calculated column is

3LetterMonth = FORMAT(table_name[FirstOfMonth],"MMM")

 

DustyC_0-1673534226883.png

 

1 ACCEPTED SOLUTION
Syk
Super User
Super User

You don't need to format this as a date. You can extract the first 3 letters from your month and then sort the column.

Syk_0-1673534913123.png

 

Select your field (mine is "first 3") and click column tools > Sort by columns > month number (or months if they're sorted correctly)

 

This will give your abbreviated column the sort order you expect.

 

 

View solution in original post

3 REPLIES 3
Syk
Super User
Super User

You don't need to format this as a date. You can extract the first 3 letters from your month and then sort the column.

Syk_0-1673534913123.png

 

Select your field (mine is "first 3") and click column tools > Sort by columns > month number (or months if they're sorted correctly)

 

This will give your abbreviated column the sort order you expect.

 

 

Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Use a date table lile this (with MonthNumber and MonthName)

Month number

Mikelytics_0-1673534815409.png

 

Month Name:

Mikelytics_1-1673534849251.png

 

Now use the sort by column feature -> sort name by number

Mikelytics_2-1673534884669.png

 

When you now use the name column it will be sorted correctly.

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
FreemanZ
Super User
Super User

hi @Anonymous 

why not directly reference the date column, try like:
3LetterMonth = FORMAT(table_name[date],"MMM")

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.