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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
talitanieps
Advocate I
Advocate I

How to order months in a Calendar Table differently (in DAX or M)?

Hello PBI Community!


I have been researching this for few days now, and I can't seem to do it, it's driving me nuts! Hope you're able to help me with a solution for my case.... Here we go! 😄

So, I'm working in a report to display the performance of ad campaigns, through time; our idea is to compare same months of the campaigns, for instance: april 2021 with april 2022, and in order to do that I need to sort months differently than by the number of the month.

so, for example, instead of showing in the graph the numbers from Jan, Feb, Mar, Apr, i'd like the graph to start in April:

campaign startendmonth_Nomonth order
202101/11/202130/05/2021111
   122
   13
   24
   35
   46
   57
202201/05/202230/11/202251
   62
   73
   84
   95
   106
   117


In this graph, which is as-is today, we can see numbers from jan to dec, but since the campaign started actually in november (in orange), the correct order would be nov, dec, jan, feb.....
orange = 2021
blue = 2022

talitanieps_0-1680521746720.png


I tried creating a table in excel, with the order previously set for each campaign, but it didn't work; I'd like to come up with a DAX-Column code that understands that and returns the month order as per explained.. The thing that it's making it more difficult (at least, in my eye) is the need to reference this campaign, so there's this conditional factor, for the campaigns are different among products, and have different start months and end months, each year.... so I can't just hard code the month order for each campaign, the ideal would be to come up with a code, either in M or DAX... 

How could I possibly achieve that in PBI?
Thanks a lot for your assistance!

 

2 REPLIES 2
amitchandak
Super User
Super User

@talitanieps , You need have two column like

 

Month = format([Date], "mmm")

 

Month Sort = if(month([Date]) <4, month([Date]) +9 , month([Date]) -3)

 

then mark month Sort as Sort column on Month and use month in visual

 

How to Create Sort Column and Solve Related Errors:
https://www.youtube.com/watch?v=KK1zu4MBb-c

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello Amit,


Thanks a lot for your comment - I ended up using rankx, which gave me the same results as your proposed solution, you comment guided me to the right path, thanks a lot!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.