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
Anonymous
Not applicable

Last 24 months dax query

Hi everyone, 

I'm trying to calculate no of orders with first order date within the last 24 months. I have a model that looks like this.

ejones_2525_0-1612189997884.png


I'm trying to achieve this. 

ejones_2525_1-1612190042949.png


Normally, the formula below works for me. It seems due to the modelling and some filter context that I have not been able to figure out, it is not grouping the items properly.

repeat orders last 24 months =
VAR maxfirstorderdate = MAX('repeat orders'[First Order Date])
RETURN
CALCULATE(
sum(order),
DATESBETWEEN('repeat orders'[First Order Date], EOMONTH(maxfirstorderdate, -24)+1, maxfirstorderdate
))

Looking forward to suggestions!
thanks
2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous - I would attach this by using FILTER to get a virtual table in a VAR and then use MINX to grab the first date. 

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler  

I tried your documentation in the links you sent, however it didn't work for me unfortunately

thanks again for the reply

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.