Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculate Moving Average

Hi,

I have data which looks like:

SiteDateValueMoving Average
London01-01-20220.10.1
London28-01-20220.20.15
London01-02-20220.30.2
London01-03-20220.60.3
London01-04-20220.120.48
Bradford01-01-202211
Bradford25-01-202232
Bradford11-02-202211.6
Bradford01-03-202252.5
Bradford16-04-2022104

I want to calculate moving average of val column. I have included manual calculations in last column for your reference

  • Moving AVG = 
    AVERAGEX(
        WINDOW(
            1, ABS,
            0, REL,
            DATA,
            ORDERBY( DATA[Date] ),
            DEFAULT,
            PARTITIONBY( DATA[Site] ),
            MATCHBY( DATA[Site], DATA[Date] )
        ),
        DATA[Value]
    )

4 Replies

  • Moving AVG = 
    AVERAGEX(
        WINDOW(
            1, ABS,
            0, REL,
            DATA,
            ORDERBY( DATA[Date] ),
            DEFAULT,
            PARTITIONBY( DATA[Site] ),
            MATCHBY( DATA[Site], DATA[Date] )
        ),
        DATA[Value]
    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Could you please tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

     

    Best regards,
    Community Support Team_Binbin Yu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.