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! Learn more

Reply
Anonymous
Not applicable

Dynamic Period Value comparison of last N Months

I basically need to compare enagaged value to last compare N months as period and assign a value. which technically should fall like this: 

DateContactEngagedPreviousEngagedStatus
01-04-2020CON-121  
02-04-2020CON-130  
03-04-2020CON-140  
04-04-2020CON-150  
05-04-2020CON-160  
06-04-2020CON-170  
07-04-2020CON-180  
08-04-2020CON-191  
09-04-2020CON-200  
10-04-2020CON-211  
01-05-2020CON-1211Retained
02-05-2020CON-1310Not Retained
03-05-2020CON-1410Not Retained
04-05-2020CON-1510Not Retained
05-05-2020CON-1610Not Retained
06-05-2020CON-1700Retained
07-05-2020CON-1810Not Retained
08-05-2020CON-1901Not Retained
09-05-2020CON-2010Not Retained
10-05-2020CON-2101Not Retained
01-06-2020CON-1211Retained
02-06-2020CON-1301Not Retained
03-06-2020CON-1411Retained
04-06-2020CON-1501Not Retained
05-06-2020CON-1611Retained
06-06-2020CON-1700Retained
07-06-2020CON-1801Not Retained
08-06-2020CON-1910Not Retained
09-06-2020CON-2001Not Retained
10-06-2020CON-2100Retained
4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , not very clear. Try with a date calendar

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))
Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-12,MONTH))


Rolling 12 till last 12 month = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(dateadd(Sales[Sales Date],-12,month)),-12,MONTH))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @Amit for the reply but that rolling 12 month period or rather N month period wanted to set up as dynamic value as in when we select the date field or text box so that we can mention the time period that should automatically  be implied in the calculation

Greg_Deckler
Community Champion
Community Champion

@Anonymous See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __Previous = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Value])
RETURN
  __Current - __Previous



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

Thanks for the reply but my requirement is - I need to compare last N months window based on input selection which is dynamic and once that is calculated i have to compare the particular month value to present day-month and provide a value.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.