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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

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
Super User
Super User

@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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors