I have the below query which gives me the headcount per month when I select a month from the date table which is fine and works correctly.
I would like the average headcount for the past 12 months from the selected date e.g if i select Aug 2020, the average should be a sum of headcount from July 2019 - Aug 2020
Active Employees =
var currentdate = 'Date'[Max Date]
RETURN
CALCULATE(
DISTINCTCOUNT('Joined Query'[EMP_NO]),
'Joined Query'[DATE_OF_EMPLOYMENT] <= currentdate,
or(
ISBLANK('Joined Query'[DATE_OF_LEAVING]),
'Joined Query'[DATE_OF_LEAVING] > currentdate
)
)