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
GUA
Frequent Visitor

Rolling 12 Month Average

Hi,

 

I am trying to calculate a Rolling 12 Month, but my DAX expression is failing. Can somone help me, please?

 

Rolling 12 Month Average = CALCULATE(AVERAGE('KPI_NumberOfIncidents (2)'[NUMBER OF INCIDENTS]);
   DATESINPERIOD('KPI_NumberOfIncidents (2)'[YEAR_MONTH];'KPI_NumberOfIncidents (2)'[YEAR_MONTH];-11;MONTH)
         )

 

Thanks!

 

- Gitte

3 REPLIES 3
CheenuSing
Community Champion
Community Champion

Hi @GUA

 

I am giving below the methodology.

 

Breakdown of logic.

  1. First calculate the [yourmeasure] of whatever - sales value etc.etc. for the last 12 months using
  2. Last12MCounts = CALCULATE (     [yourmeasure],     DATESBETWEEN (   MasterCalendar[Date],  NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( MasterCalendar[Date] ) ) ),         LASTDATE ( MasterCalendar[Date] )     ) ) 
  3. What it does it filters the calendar table for all the days in the last 12 months from the current date context.

Let us say you are showing the data for July 2017. Then we take the last visible date in the month using

LASTDATE ( MasterCalendar[Date] which will return 31 Jul 2017.

 

Then SAMEPERIODLASTYEAR is evaluated as SAMPEPERIODLASTYEAR( 31 Jul 2017) which will return 31 Jul 2016.

This is then wrapped with NEXTDAY function to return the value 01 AUG 2016.

Then DatesBetween 01 AUG 2016 and 31 JUL 2017 represents the whole year.

 

This assumes you have a date ( master calendar) dimension table.

 

 

If this works for you please accept this as a solution and also give KUDOS.

 

Cheers

 

CheenuSing 

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Hi,

 

Unfortunately I don't have a date dimension table. 😞

 

I have tried som other stuff, but now I am stucked again...

 

Udklip.PNG

 

- Gitte

Hey,

You can use a 'quick measure' to get the rolling average pretty easy.
As long as your data is clean

Greetings

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.