Forum Discussion
Cosmo01
4 years agoFrequent Visitor
Calculate 26 weeks moving average
Hello folks, i need to make a 26week rolling average measure. i need to show this on a line chart along with weekly sales. i tried with a measure like this, but i'm only getting the week's ac...
- 4 years ago
Hi,
It is quite hard to write a measure without seeing the pbix file, but please try the below.
AVG 26 week = VAR _max1 = MAX ( 'Date'[Date] ) VAR _min1 = _max1 - 182 RETURN AVERAGEX ( ADDCOLUMNS ( SUMMARIZE ( FILTER ( ALL ( 'Date' ), 'Date'[Date] >= _min1 && 'Date'[Date] <= _max1 ), 'Date'[Date_WK_Ending] ), "@weeklysales", [YourSalesMeasure] ), [@weeklysales] )
Jihwan_Kim
4 years agoSuper User
Hi,
It is quite hard to write a measure without seeing the pbix file, but please try the below.
AVG 26 week =
VAR _max1 =
MAX ( 'Date'[Date] )
VAR _min1 = _max1 - 182
RETURN
AVERAGEX (
ADDCOLUMNS (
SUMMARIZE (
FILTER ( ALL ( 'Date' ), 'Date'[Date] >= _min1 && 'Date'[Date] <= _max1 ),
'Date'[Date_WK_Ending]
),
"@weeklysales", [YourSalesMeasure]
),
[@weeklysales]
)
- Cosmo014 years agoFrequent Visitor
Thank you! this worked