> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# MovingVariance

> Use the Sigma MovingVariance function to calculate the statistical variance of a column in a moving window.

The **MovingVariance** function calculates the statistical variance of a column in a moving window.

## Syntax

```
MovingVariance([column], above, below)
```

Function Arguments:

* **\[column]** (required) - The column of numbers to calculate the variance.
* **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

A table contains the daily close price of a stock in 2016. Variance can be used to show the volatility of a stock, where a higher variance indicates higher risk. We can use the **MovingVariance** function to identify the change in variance in different moving windows.

```
MovingVariance([Close Price], 4)
```

With \[Close Price] as the **column** argument and 4 as the **above** argument, the variance is calculated for each week along with the four previous weeks. Since the **below** argument is not specified, it defaults to 0.  

![A table with Day, Close Price, and Moving Variance columns, highlighting the current day and four previous days of close prices that produce a moving variance of 0.31 for 2016-04-20.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/201b5221b437048e354e1df21ba91c304d7f73e88743fe122c1f276b52cda523/assets/docs-images/0073df5-1.png)

```
MovingVariance([Close Price], 0, 4)
```

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

![A table with Day, Close Price, and Moving Variance columns, highlighting 2016-04-14 and the next four days of close prices, which produce a moving variance of 0.31 for that day.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/599f3d2e12faf4cec73788d52afafe687f296d0fb9e8ed66e3ca0ab727658f52/assets/docs-images/c74a6da-2.png)

```
MovingVariance([Close Price], 2, 2)
```

Here, the **above** argument is 2, so the previous two weeks are included in the window. In addition, the **below** argument is 2, so the following two weeks are included as well.

![A table with Day, Close Price, and Moving Variance columns, highlighting the two days before and after 2016-04-18, which produce a moving variance of 0.31 for that day.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/3152cff622e8cffa2a71fe1ab8a8deae9fc8267fa73d40ab6a42c1f7a4e7a6dc/assets/docs-images/b41073b-3.png)

```
MovingVariance([Close Price], 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.

![A table with Day, Close Price, and Moving Variance columns, highlighting the window from eight to four days before 2016-04-26, which produces a moving variance of 0.31 for that day.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/c12c7295d1df11fc99ebacd737bd7dfddf057fe7b974d68a9653c1c41145680e/assets/docs-images/f8c9e62-4.png)

## Related resources

* [CumulativeVariance](/docs/cumulativevariance)
* [Variance](/docs/variance)