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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Sudhavi_84
Helper V
Helper V

MM-DDDD Sorting Order in Column Visual

HI Experts,

I have 4 different calculated Date columns based on criteria, Which I am using for 4 different Column Visuals.

I want to sort Date Columns in to MM-YYYY Order in Column Visual (Horizontal)

I can add 4 more columns for each date column and then  I can give groupings and sort the order.

 

But with out adding 4 more columns, can I sort the my Horizontal Column Visual in Order?  (Yellow is Blank which has no dates)

I converted Date Column Data Type to MM-YYYY and also tried to Formatted to "MM-YYYY"  but it is not sorting order.

 

Sudhavi_84_0-1622041997364.png

 

Thanks in Advance

1 ACCEPTED SOLUTION

Hi @Sudhavi_84 ,

 

Yes, the code I gave was for a new column in Power Query, as DAX calculated columns are not generally recommended.

If you really need to do it in DAX, then the column formula would be:

..yearMonthSortKey = YEAR(yourTable[Date]) * 100 + MONTH(yourTable[Date])

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

5 REPLIES 5
BA_Pete
Super User
Super User

Hi @Sudhavi_84 ,

 

Create a [yearMonth] field in your calendar.

 

In Power Query your column calc would be something like this:

Date.Year([Date]) * 100 + Date.Month([Date])

 

Once you have this column, you can use it as a Sort By column for your MM-YYYY column.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thank you @BA_Pete  for your quick response.

 

I have MMMYYYY column in calendar. Which is perfect as below in calendar table.

Sudhavi_84_1-1622046130907.png

 

 

Next I am going to table-->Adding Column-->Date.Year is greying out not showing me anything. Please let me know if I am missing something here.  

MMYYYY = Date.Year   (I am getting below error)

Sudhavi_84_0-1622045976792.png

 

Please any help?

 

 

Is this something we need to write in Power Query (M Editor)? Not in new calculated column?

Hi @Sudhavi_84 ,

 

Yes, the code I gave was for a new column in Power Query, as DAX calculated columns are not generally recommended.

If you really need to do it in DAX, then the column formula would be:

..yearMonthSortKey = YEAR(yourTable[Date]) * 100 + MONTH(yourTable[Date])

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Perfect Thank You

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors