> 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.

# MovingCorr

> Use the Sigma MovingCorr function to calculate the Pearson correlation coefficient, also known as the bivariate correlation, of two numerical.

The **MovingCorr** function calculates the Pearson correlation coefficient, also known as the bivariate correlation, of two numerical columns within a moving window.

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

## Syntax

```
MovingCorr([Number Column 1], [Number Column 2], above, below)
```

Function Arguments:

* **\[Number Column 1]** (required) - The column representing the dependent data.
* **\[Number Column 2]** (required) - The column representing the independent data.
* **above** (required) - The first row to include, counting backward 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 of sales data lists quantity sold and total sales by day. You can use the **MovingCorr** function to find the relationship between the total sales of an item and the amount of an item that's purchased within several types of moving windows.

```
MovingCorr([Weekly Quantity Sold], [Total Weekly Sales], 4)
```

Here, the **above** argument is 4, so the correlation between \[Total Weekly Sales] and \[Total Quantity Sold] is computed for the previous 4 weeks. Because the **below** argument is not specified, it defaults to 0 and no future weeks are considered.

![A table with Week of date, Weekly Quantity Sold, Weekly Sales, and Moving Correlation columns, with 5 rows from 2019-05-26 to 2019-06-23 highlighted and a Moving Correlation of -0.19 highlighted on the final row, 2019-06-23.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/3d5a36f7aa16b45107af14485282cac9f248d574ed4f7bdc4a183da81a69fd1d/assets/docs-images/ac06c4f-1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260914%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260914T204950Z&X-Amz-Expires=604800&X-Amz-Signature=1fb1f6aa64345dcc21a56baf3ebd75fe3a01b5c43729524e2c26b1736b2bab02&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

```
MovingCorr([Weekly Quantity Sold], [Total Weekly Sales], 0, 4)
```

Here, the **above** argument is 0, so no previous weeks are included in the calculations. The **below** average is 4, therefore the moving correlation is computed for each week along with the next 4 weeks.

![A table with Week of date, Weekly Quantity Sold, Weekly Sales, and Moving Correlation columns, with 5 rows from 2019-05-26 to 2019-06-23 highlighted and a Moving Correlation of -0.19 highlighted on the first row, 2019-05-26.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/4f2aa82c2b42c7c13f2628ded8d789431172e87120b40dca2173fe048cb9a222/assets/docs-images/75b2755-2.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260914%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260914T204950Z&X-Amz-Expires=604800&X-Amz-Signature=f8bf12f9f67a36c4a4439e56da9ed1ac11574443d37e49f82519d288e1ba9383&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

```
MovingCorr([Weekly Quantity Sold], [Total Weekly Sales], 2, 2)
```

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

![A table with Week of date, Weekly Quantity Sold, Weekly Sales, and Moving Correlation columns, with 5 rows from 2019-05-26 to 2019-06-23 highlighted and a Moving Correlation of -0.19 highlighted on the middle row, 2019-06-09.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/fd667388e100691cf873a09ca01e1a1f61a27a6d88480090043db72eaff7934f/assets/docs-images/f969622-3.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260914%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260914T204950Z&X-Amz-Expires=604800&X-Amz-Signature=5eebd7516c2567d5ade04b674d5d4d579f9e5b03679b03b9840da4529b07a37a&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

```
MovingCorr([Weekly Quantity Sold], [Total 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.

![A table with Week of date, Weekly Quantity Sold, Weekly Sales, and Moving Correlation columns, with 5 rows from 2019-05-26 to 2019-06-23 highlighted and a Moving Correlation of 0.19 highlighted on the row for 2019-07-21.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/af487109e74dbb0e7186dcd0ce073e158bbea2e23db7f6f93d6d2a42b1362b15/assets/docs-images/3c0936e-4.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260914%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260914T204950Z&X-Amz-Expires=604800&X-Amz-Signature=a6ef55c093da35393ad0662e060641d88e81d4de0a0a7a05d3080685395b9146&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

## Related resources

* [Corr](/docs/corr)
* [CumulativeCorr](/docs/cumulativecorr)