# MovingAvg

TheΒ MovingAvg function calculates the numerical average of a column within a moving window. Β

## Syntax

`MovingAvg(\[column\], above, below)`

Function Arguments:

• [column] (required) The column of numbers to average.
• above (required) The first row to include, counting backwards from the current row.
• below (optional) The last row to include, counting forward from the current row. Defaults to 0 (current row will be the last row included).

## π

When using this function without a sort enforced, there can be unexpected results. In order to ensure that the values are stable, verify that there is a sorted column within the table.

## Example

The following table lists the weekly sales for the past year. Β The table is sorted ascending by the week.

The MovingAvg function can be utilized in order to calculate the average within specific windows.

`MovingAvg(\[Weekly Sales\], 4)`

With [Weekly Sales] as the column argument and 4 as theΒ above argument, the average weekly sales will be calculated for each week along with the four previous weeks. Since the below argument was not specified, it defaults to 0. Β

`MovingAvg(\[Weekly Sales\], 0, 4)`

Here, the above argument is 0, so there will not be any previous weeks included in the average. Β TheΒ below average is 4, so the average weekly sales will be computed for each week along with the next 4 weeks.

`MovingAvg(\[Weekly Sales\], 2, 2)`

Here, theΒ above argument is 2, so the previous two weeks will be included in the average. In addition, the below argument is 2, so the following two weeks will be included as well.

`MovingAvg(\[Weekly Sales\], 8, -4)`

Here is an example where theΒ below parameter is negative. The below parameter can be negative as long as the value is less than that of theΒ above parameter. In this example, each window begins 8 weeks before the current week and ends 4 weeks before the current week, inclusive.

Related resources