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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

cant sort by year month column - Can we create a measure for sorting

I was working on a pbi report where data source is Cube. When i create a chart and sort by month and year column(Data format is string) it not coming correctly (As attached). can we create a meaure on PBI for sorting this 

 

samz_1-1594196132325.png

 

2 ACCEPTED SOLUTIONS
Daviejoe
Memorable Member
Memorable Member

I have a column which gives me the month number and then i create another column and use the below to sort the month & year

 

Month Year Short Index =
('Date'[Year] * 100) + 'Date'[Month No.]




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

Proud to be a Super User!




View solution in original post

@Anonymous , Only two M

FORMAT(FactPortfolio[DateKey],"YYYYmm")

 

And made this sort column no need to use in visual. In visual you can use your old column

refer

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

8 REPLIES 8
Daviejoe
Memorable Member
Memorable Member

I have a column which gives me the month number and then i create another column and use the below to sort the month & year

 

Month Year Short Index =
('Date'[Year] * 100) + 'Date'[Month No.]




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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , No you need column. Please check  if creation on the column is allowed

If you have month year in the format

Month Year = FORMAT([Date],"mmm-yyyy")

you need a sort column like this
Month Year sort = FORMAT([Date],"yyyymm")

 

follow steps

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak

I tried to chnages the format but still it not resolved.

FORMAT(FactPortfolio[DateKey],YYYYmmm)

samz_0-1594197870588.png

Let me know if you try my method @Anonymous 





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

Proud to be a Super User!




Anonymous
Not applicable

@Daviejoe 

I tried this way aswell, Same result. Thanks A lot . Really helped me 

@Anonymous Happy to help.





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

Proud to be a Super User!




@Anonymous , Only two M

FORMAT(FactPortfolio[DateKey],"YYYYmm")

 

And made this sort column no need to use in visual. In visual you can use your old column

refer

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

yes its working now. Thanks a lot. 

 

 

samz_0-1594200681101.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.