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

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

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

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

Anonymous
Not applicable

@amitchandak 

yes its working now. Thanks a lot. 

 

 

samz_0-1594200681101.png

 

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.