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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
codyraptor
Resolver I
Resolver I

DAX compare months in ascending vs months in descending

I know this is probably a strange request...haven't seen too much on this.  I need to calculate Jan - Dec metrics...but display them in reverse.  Below is an example....  I want PY Q3-4 to align with Current year Q1-2...and PY Q1-2 to align with Current Year Q3-4.  Anyone know of a blog post about doing something like this?  The end result will display current year actuals...but I plan to use this calculation for future months.

codyraptor_1-1659045891123.png

 

 

 

1 ACCEPTED SOLUTION
codyraptor
Resolver I
Resolver I

I found a result that seems to work for me by just adding specific months to the max month.  Thanks!

View solution in original post

4 REPLIES 4
codyraptor
Resolver I
Resolver I

I found a result that seems to work for me by just adding specific months to the max month.  Thanks!

v-yalanwu-msft
Community Support
Community Support

Hi, @codyraptor ;

please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

codyraptor
Resolver I
Resolver I

The dax I used to pull each month is not efficient.  It's taking quite a bit of time to calculate each month.  I've tried to use a fitler only on the date..and possibly pass the measure 1 time through the variable like below...but I get zero results.  Any suggestions?

 

Var SelectedMonth = max('Dispatch Date'[Dispatch Month Num])
Var MonthCalc = SWITCH(TRUE(),
SelectedMonth = 1,  DATESINPERIOD('Dispatch Date'[Dispatch Date], SelectedMonth, -1, Month),
SelectedMonth = 2,  DATESINPERIOD('Dispatch Date'[Dispatch Date], SelectedMonth, -3, Month))
Return
Calculate( [Disp Ratio Spread Baseline], KEEPFILTERS('Dispatch Date'[Dispatch Date] = MonthCalc))

codyraptor
Resolver I
Resolver I

I can break this down by month and it works...just really long dax.  Possible ways to make this cleaner?

SWITCH(TRUE(),
max('Dispatch Date'[Dispatch Month Num])=1, CALCULATE([Measure], dateadd('Dispatch Date'[Dispatch Date],-1,Month)),
max('Dispatch Date'[Dispatch Month Num])=2, CALCULATE([Measure],, dateadd('Dispatch Date'[Dispatch Date],-3,Month)))

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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