Formula for R2 in Excel: How to Calculate It Fast
In this article
The fastest way to calculate R-squared (R²) in Excel is with the RSQ function: type =RSQ(known_ys, known_xs) in any cell, replacing the two arguments with your data ranges. R², also called the coefficient of determination, tells you how well your independent variable (x) predicts your dependent variable (y) on a scale from 0 to 1 — the closer to 1, the better the fit. Below are the main ways to get it, including the manual formula and the chart method.
What You'll Need
- Excel (Microsoft 365, Excel 2019, 2016, or the free Excel for the web all have the RSQ function)
- Two columns of paired numeric data: your independent variable (x values) and dependent variable (y values)
- Each x value must have a matching y value in the same row
Step-by-Step
Method 1: The RSQ function (recommended)
- Open your spreadsheet and confirm your x values are in one column and your y values in another. For example, x in A2:A21 and y in B2:B21.
- Click an empty cell where you want the R² value to appear.
- Type =RSQ( then select the y range, type a comma, then select the x range. It should look like =RSQ(B2:B21, A2:A21). Note the order: y values first, then x values.
- Press Enter. The cell shows the R² value, for example 0.87.
- To display it with more precision, select the cell and use the Increase Decimal button on the Home tab, or press Ctrl+1 to open Format Cells and choose a number format.
Method 2: Square the correlation coefficient
- Click an empty cell.
- Type =CORREL(range_y, range_x)^2 — for example =CORREL(B2:B21, A2:A21)^2.
- Press Enter. Because R² is literally the square of the Pearson correlation coefficient (r), this gives the same result as RSQ for a simple linear relationship.
Method 3: Get R² from a trendline on a chart
- Select both data columns, then go to Insert > Charts and choose a Scatter chart.
- Click any data point on the chart, then click the plus (+) button beside the chart and check Trendline, or right-click a point and choose Add Trendline.
- In the Format Trendline pane that opens, scroll down and tick Display R-squared value on chart.
- The R² value appears as a small label next to the trendline.
Method 4: The manual formula
- Use the full formula in one cell: =1 - (SUMPRODUCT((y - predicted_y)^2) / SUMPRODUCT((y - AVERAGE(y))^2)), where predicted_y comes from your regression line. This mirrors the textbook definition R² = 1 − (SS_res / SS_tot) and is mostly useful for learning or checking other results.
Menu and pane labels can differ slightly between Excel versions and between desktop and Excel for the web, but the function names are identical everywhere.
Common Mistakes
- Swapping the arguments. RSQ expects y values first, then x values. For a simple linear fit the result is actually the same either way, but getting in the habit of the right order matters when you move on to other functions.
- Unequal range lengths. If your x and y ranges contain different numbers of cells, RSQ returns a #N/A error.
- Text or blank cells inside the ranges. Text, empty cells, or error values are ignored in pairs, which can silently shrink your dataset and distort the result.
- Misreading what R² means. A high R² shows correlation, not causation, and R² from a trendline on a line chart can differ from the scatter-chart value because Excel interpolates the data differently. Always use a Scatter chart for trendlines.
- Forgetting R² can be misleading with few data points. With only a handful of rows, R² swings wildly and means very little.
Tips
- Make your ranges absolute (e.g. $B$2:$B$21) with F4 if you plan to copy the formula elsewhere.
- Name your ranges (Formulas > Define Name) so formulas read like =RSQ(Sales, AdSpend) instead of cell references.
- For multiple regression (more than one x variable), RSQ works too — just pass the x range as a multi-column block, or use the Regression tool in the Analysis ToolPak (File > Options > Add-ins) which reports R² alongside other statistics.
- Use Method 3 when presenting to others: the on-chart R² label is easier to read at a glance than a cell value.
- Round for display only. Keep the raw value in the cell and format it rather than wrapping it in ROUND, so downstream calculations stay precise.
Troubleshooting
- #N/A error: your x and y ranges are different sizes. Make both ranges cover exactly the same rows.
- #DIV/0! error: all your x values (or all your y values) are identical, so variance is zero and R² is undefined. Check for a copied column or a range pointing at the wrong data.
- The trendline pane has no R-squared option: you are probably on a non-scatter chart type (some chart types, like moving average trendlines on certain data, hide the option). Recreate the chart as a Scatter chart.
- RSQ result looks wrong compared to the chart: confirm you selected a linear trendline — an exponential or polynomial trendline reports a different R².
- Analysis ToolPak is missing: go to File > Options > Add-ins, select Excel Add-ins at the bottom, click Go, and tick Analysis ToolPak.
- Everything else fails: copy your data to a fresh workbook and try again — this rules out hidden formatting, filters, or merged cells interfering with the ranges.
Frequently Asked Questions
What is the exact formula for R2 in Excel?
=RSQ(known_ys, known_xs). Pass the dependent (y) values first and the independent (x) values second, for example =RSQ(B2:B21, A2:A21).
Is there a difference between RSQ and CORREL squared?
No. For a single x variable, RSQ(range_y, range_x) and CORREL(range_y, range_x)^2 always return the same number.
Can I calculate R² for multiple regression in Excel?
Yes. Pass a multi-column range as the x argument to RSQ, or run the Regression tool in the Analysis ToolPak, which reports R² and adjusted R².
What is a good R² value?
It depends on the field. In physics or engineering, values above 0.9 are often expected; in social science or marketing data, 0.3–0.6 can be perfectly useful. Compare against what is normal for your type of data.
Does R² work with negative or zero values?
Yes. R² is scale-independent and works with any numeric values, including negatives and zeros — just not with text, blanks, or a completely constant x column.
Does Excel for the web and Excel on mobile support RSQ?
Yes, the RSQ and CORREL functions work in Excel for the web and in the Excel mobile apps, so you can calculate R² without the desktop version.