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
socalkid
New Member

Need help constructing a basic 3, 6, and 12 month moving average

Hello all,

I have a question re: how to calculcate a moving 3 month, 6 month and 12 month average for some headcount data. My main data table looks like this: 

 

socalkid_0-1680994604597.png

 

So I have the count by date, department, work category and location. My goal is to be able to set up a table where I can see the 3-month, 6-month, and 12-month averages for each location, department, work category and then sum up this average if I need to. For example, I'd like to be able to see the overall 3-month average for all of Operations in Shanghai for August 2020. Is this possible? I've been reading about setting up a date table but I'm not sure if that's required for this. Thank you in advance.

1 REPLY 1
amitchandak
Super User
Super User

@socalkid , Try like

 


3 Month Avg = CALCULATE(AverageX(Values('department'[department]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

6 Month Avg = CALCULATE(AverageX(Values('department'[department]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

 


6 Month Avg = CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-6,MONTH))

 


3 Month Avg = CALCULATE(AverageX(Values('Date'[MONTH Year]),calculate(Sum('Table'[Value)))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

 

Average of Rolling, Average of Snapshots: https://youtu.be/_pZRdLAJxxA

 

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

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.