Forum Discussion

Cosmo01's avatar
Cosmo01
Frequent Visitor
4 years ago
Solved

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...
  • Jihwan_Kim's avatar
    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]
        )