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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Monthname not sorting in unpivot columns

Hi,
I have a matrix in power bi where I want to show from the slicer if Year is selected only year should show, if Quarter then Quarter should show on the matrix and when month is selected MonthName should show. I have created a table with unpivot columns and the monthname is not sorting. Everything else works except the sorting. Please help. Thanks Dorathy

11 REPLIES 11
amitchandak
Super User
Super User

If your month is in MMM-YYYY or MMMM-YYYY format then you need a month year sort column

New column

Month Sort =format(date[date],"YYYYMM")

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

Anonymous
Not applicable

Slicer          

Day

Year 

Quarter

MonthName

Week

Day

If Monthname is selected the Matrix shows as

Department Apr 20 Feb 20 Mar 20 Jan 20

 

 
 
 
 

@Anonymous add another column for sorting month-year column and sort column

 

Month Year Sort = 
FORMAT( Table[Date], "YYYYMM" )

 

sort your month year column with above new column called Month Year Sort 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thanks for your reply, you want me to add this to the already unpivot columns table as a new column?

Anonymous
Not applicable

Values in the unpivot columns are not sorting by Month

@Anonymous doesn't matter, just follow the step, add a new sort column and sort your month name column by this new sort column as described above and it should be ok. You have to first test it and let us know if you run into an issue. It is not clear if you are actually trying the solution.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k  - This is the error I am getting 

Column 'Year Month' in table 'DateSlicer' cannot be found or may not be used in this expression.

I have this Year Month in the unpivot column along with other columns like Year, Quarter, Year Month, Week and Day

 

@Anonymous can you share pbix file, please remove any sensitive information before sharing. Unfortunately, I'm having a hard time following what issue you are facing. If you cannot share publically, my email address is in the signature and feel free to send it by email.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous yes whatever table you are using for month year column.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous you have to sort month name by month number, assuming you have month like Jan, Feb, Mar and month number 1, 2, 3,...

 

Select month name column and on column tools choose sort by , see example below, it is not exactly the same column but shows where the option are to sort by

 

image.png



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Greg_Deckler
Super User
Super User

Sample data would help. But you likely need a numeric month column and use Sort By column on you monthname. Otherwise it will sort alphabetically.

@ 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...

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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