Forum Discussion

tjowen's avatar
tjowen
Regular Visitor
7 years ago
Solved

Getting a running average

I have created a calculated table that contains two fields:  a date (no time), and a numerical value for each date.   It looks something like this:     I am trying to get a running average...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hey Tom,

     

    By including a filter, ALL(DaySum), you will achieve the results you are looking for. See below for an example.

     

     
    30 Day Average = 
    DIVIDE(
        CALCULATE(
            SUM(DaySum[Cargo Tonnes]), 
            ALL(DaySum),
            DATESBETWEEN(DaySum[Date], LASTDATE(DaySum[Date])-30, LASTDATE(DaySum[Date]))
        )
    ,30)

     

    Kind regards,
    Alex