Calculate a rolling average using measures in power pivot

misstoffeepenny

New Member
Joined
Jan 18, 2021
Messages
19
Office Version
  1. 365
  2. 2016
  3. 2011
Platform
  1. Windows
Hi all, I've been trying to calculate the rolling average of 'employee count' to use in within another calculation but the formula I have doesn't appear to take the last 12 months but the entire column average, any help appreciated.
Formula:
=CALCULATE((sum('Accident Log'[Count RIDDOR])/AVERAGE(EmployeeCount[Employee Count])*100000),DATESINPERIOD('Calendar'[Date],Max('Calendar'[Date]),-12,MONTH))

Note all my tables have linked relationships and link through a calendar table.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Are your “Accident log” and “employee count “ tables both joined to the calendar? Are you using columns from your calendar in your visual and not date columns from your other 2 tables?
 
Upvote 0
Hi Matt, yes all my tables are linked to the calendar & I’ve only used the calendar date columns to make the pivot tables
 
Upvote 0
This formula will take the dates in the visual, then extend those dates to include the previous 12 months. What I suggest you do is write a test formula to help you "see" what is happening. I have modified your formula here so that it will return the first and last date in the current filter context from you visual. I hope it makes sense.

VBA Code:
=
CALCULATE (
    (
        "Min: " & MIN ( 'Calendar'[Date] ) & " Max: "
            & MAX ( 'Calendar'[Date] )
    ),
    DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), -12, MONTH )
)
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top