Forum Discussion
3 month rolling average data table
- 5 years ago
Hi ArslanManzoor ,
The measure you are calculating is the average value of the previous 3 months in this case you are getting for may the values between February and April and making the average so the data is:
If you make the average you get the 40.63.
To what I read you want to have the values of the montlhy average on the last 3 month so you want that if the value is on the last 3 month show the average otherwise do not show.
Redo your measure to:
TimeTakenAverageValue = VAR MaxFactDate = CALCULATE ( MAX ( 'Calendar'[Date] ), ALL ( 'Calendar' ) ) VAR Edate = EDATE ( MaxFactDate, -2 ) RETURN SWITCH ( TRUE (), SELECTEDVALUE ( AxisTable[Month & Year] ) = "Current", CALCULATE ( [Time Taken Avg], FILTER ( ALL ( 'Calendar' ), 'Calendar'[Month & Year] <> MAX ( 'Calendar'[Month & Year] ) ) ), MAX ( 'Calendar'[Date] ) <= MaxFactDate && MAX ( 'Calendar'[Date] ) >= Edate, CALCULATE ( AVERAGE ( Data[Time taken] ) ) )check result below and in attach PBIX file.
Hi ArslanManzoor ,
The measure you are calculating is the average value of the previous 3 months in this case you are getting for may the values between February and April and making the average so the data is:
If you make the average you get the 40.63.
To what I read you want to have the values of the montlhy average on the last 3 month so you want that if the value is on the last 3 month show the average otherwise do not show.
Redo your measure to:
TimeTakenAverageValue =
VAR MaxFactDate =
CALCULATE ( MAX ( 'Calendar'[Date] ), ALL ( 'Calendar' ) )
VAR Edate =
EDATE ( MaxFactDate, -2 )
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( AxisTable[Month & Year] ) = "Current",
CALCULATE (
[Time Taken Avg],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Month & Year] <> MAX ( 'Calendar'[Month & Year] )
)
),
MAX ( 'Calendar'[Date] ) <= MaxFactDate
&& MAX ( 'Calendar'[Date] ) >= Edate, CALCULATE ( AVERAGE ( Data[Time taken] ) )
)
check result below and in attach PBIX file.