I have a measure that uses a start and end date to calculate the total number of people employed in a month. I would like to use this measure to produce a rolling 12 month average. This is my measure: -
VAR _FirstDate = MIN ( 'Dates'[Date] )
VAR _LastDate = MAX ( 'Dates'[Date] )
VAR _Filter =
FILTER (
'Employment',
'Employment'[Start] <= _LastDate
&& (
ISBLANK ( 'Employment'[End] )
|| 'Employment'[End] >= _FirstDate
)
)
RETURN
CALCULATE ( DISTINCTCOUNT ( 'Employment'[id] ), _Filter )
If I matrix the measure using a date table with month/year in Power BI I would get this:
Month Year | Employed |
---|---|
Jan-20 | 10 |
Feb-20 | 9 |
Mar-20 | 12 |
Apr-20 | 15 |
May-20 | 16 |
Jun-20 | 15 |
Jul-20 | 14 |
Aug-20 | 16 |
Sep-20 | 16 |
Oct-20 | 17 |
Nov-20 | 16 |
Dec-20 | 16 |
I cannot simply average the raw data as I need a snapshot of what the employed number was each month.
Is there a way in DAX to generate this table as a variable table and then average the Employed column, which in this example would give me an average of 14.