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

# RegressionR2

> Use the Sigma RegressionR2 function to calculate the R2 value, or coefficient of determination, of the linear regression line.

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

The **RegressionR2** function calculates the R<sup>2</sup> value, or coefficient of determination, of the linear regression line. This value is a goodness-of-fit measure, and explains how well the independent variable explains variations in the dependent variable.

The **RegressionR2** function is an aggregate function.

Aggregate functions evaluate one or more rows of data and return a single value.

In a table element, the aggregate is calculated for each grouping. For information on how to add a grouping with an aggregate calculation to a table, see [Group columns in a table](/docs/create-and-manage-tables#group-columns-in-a-table).

In a table with no groupings, the aggregate is calculated for each row. For information on how to calculate summary statistics across all rows in a table, see [Add summary statistics to a table](/docs/create-and-manage-tables#add-summary-statistics-to-a-table).

To learn more about using aggregate functions, see [Building complex formulas with grouped data](https://www.sigmacomputing.com/resources/training-videos/table-grouping-and-functions#complex-formulas).

## Syntax

```
RegressionR2(y, x)
```

### Function arguments

|       |                                                                           |
| :---- | :------------------------------------------------------------------------ |
| **y** | The dependent variable, expected to change as a result of changes in `x`. |
| **x** | The independent variable.                                                 |

## Notes

* The function returns null if the arguments used provide only a single data point.

## Example

A table contains an *AdSpend* column (tracking monthly advertising spend) and a *Revenue* column (tracking month revenue). You can use the **RegressionR2** function to calculate how well advertising spend explains variations in revenue.

```
RegressionR2([Revenue], [AdSpend])
```

Possible output values range from `0` (no correlation) to `1` (perfect correlation), representing a percentage from 0 to 100. If the output is `0.4`, for example, 40% of the variation in revenue can be explained by changes in advertising spend.