Search code examples
excel-formulaformularolling-computationrolling-average

3 days moving average in excel


I am trying to calculate the 3-day moving average in excel. And I want excel to not calculate the moving average if any one day (out of 3 days of daily precipitation data) contains a zero value. Can anyone help and guide thank's

3day_moving.average


Solution

  • The formula in E4 can be

    =IF(COUNTIF(D2:D4,0)>0,"",AVERAGE(D2:D4))

    It will count the number of occurrences of zeros in last three days, if the count has some value (>0) it will show a blank and if not it will show the average of last three days