How to Find R Square in Excel: Step-by-Step
In this article
To find R-squared in Excel, you can either add a trendline to a scatter chart and display its R-squared value, or use the RSQ function directly in a cell. The fastest method is the RSQ function: type =RSQ(known_y's, known_x's) and select your data ranges. Both methods give the same result. You will need two columns of paired numeric data (the independent variable in one column, the dependent variable in the other) with no blank cells inside the ranges.
What You'll Need
- Excel for Windows, Mac, or Excel for the web (the steps are nearly identical; menu labels may differ slightly by version and region).
- Two columns of numeric data: one for the independent variable (X) and one for the dependent variable (Y). Each row should be a matched pair.
- At least two data points. More points give a more meaningful R-squared, but Excel will calculate it with two.
- Optional: a scatter chart if you prefer the trendline method.
Step-by-Step
- Lay out your data. Put the X values in one column (for example, A2:A20) and the corresponding Y values in the next column (B2:B20). Do not leave blank rows inside the ranges. If you have headers, keep them out of the selected ranges.
- Pick an empty cell where you want the R-squared value to appear.
- Enter the RSQ formula. Type
=RSQ(then select the Y range, type a comma, select the X range, and close the parenthesis. For example:=RSQ(B2:B20, A2:A20). Press Enter. The result is a number between 0 and 1 (or 0 and -1 if the slope is negative; R-squared itself is always between 0 and 1). - Format the result as a decimal or percentage. Select the cell, then use the Number Format dropdown on the Home tab to show more decimal places or a percentage. R-squared is often shown as a percentage (for example, 0.85 becomes 85%).
- Alternative: use a scatter chart trendline. Select your two columns (including headers if you have them), go to Insert > Scatter, and choose the first scatter chart option (markers only).
- Add a trendline. Click any data point in the chart to select the series, right-click, and choose Add Trendline. In the Format Trendline pane (or the trendline options dialog on Mac), select Linear.
- Display the R-squared value. In the same pane, check the box labeled Display R-squared value on chart. The value appears on the chart. You can drag the label to reposition it.
- Verify both methods match. The trendline R-squared and the RSQ function result should be identical. If they differ, check that both use the same ranges and that no blank cells or text values are included.
Common Mistakes
- Swapping X and Y ranges. RSQ is not symmetric:
=RSQ(Y, X)is correct for predicting Y from X. Reversing the arguments gives a different (and usually wrong) value for your purpose. - Including headers in the ranges. Text in a range causes RSQ to return a #VALUE! error or ignore rows. Select only the numeric cells.
- Leaving blank cells inside the range. Blank cells can cause mismatched ranges or errors. Use contiguous ranges or clean the data first.
- Using R-squared for non-linear data. RSQ and a linear trendline measure linear fit only. For curved relationships, a linear R-squared can be misleading; consider other analysis.
- Confusing R-squared with correlation. R-squared is the square of the correlation coefficient (r). If you need r, use the CORREL function or take the square root of R-squared (keeping the sign of the slope).
- Expecting RSQ to handle text or errors. RSQ ignores text and logical values in ranges but returns an error if the two ranges have different numbers of data points.
Tips
- Use named ranges (Formulas > Define Name) to make formulas like
=RSQ(Sales, Advertising)easier to read and audit. - Press F4 while editing the formula to toggle absolute references if you plan to copy the formula.
- For a quick visual check, add a linear trendline and look at the R-squared value; a value near 1 indicates a strong linear fit, near 0 a weak one.
- If you need more regression statistics (slope, intercept, standard error), use the Analysis ToolPak: File > Options > Add-ins > Excel Add-ins > Go > check Analysis ToolPak, then Data > Data Analysis > Regression.
- Keep your X and Y columns adjacent and clearly labeled; this reduces range-selection errors.
Troubleshooting
- #VALUE! error: Check that both ranges contain only numbers (no text, no blank cells that Excel interprets as zero). Remove or exclude non-numeric cells.
- #N/A error: The two ranges have different numbers of cells. Make sure both ranges cover the same number of rows.
- Result looks wrong or is negative: RSQ returns a value between 0 and 1 for a positive linear relationship; a negative slope still yields a positive R-squared. If you get a negative number, you likely used a different function or reversed arguments incorrectly. Double-check the formula syntax.
- Trendline R-squared does not appear: Ensure the trendline options include Display R-squared value on chart. On some Excel versions, the option is in the Format Trendline pane under Trendline Options.
- Chart shows a curved pattern: A linear trendline may not fit; R-squared will be low. Consider a different trendline type (exponential, logarithmic) but note that RSQ only works for linear relationships.
- Formula not calculating: Check that Calculation Options is set to Automatic (Formulas > Calculation Options > Automatic).
Frequently Asked Questions
What is the difference between RSQ and the trendline R-squared?
They are mathematically identical for a linear trendline. RSQ calculates the square of the Pearson correlation coefficient; the trendline displays the same value. Use whichever is more convenient.
Can I use RSQ with non-numeric data?
No. RSQ requires numeric values. Text, logical values, and empty cells are ignored, but if the two ranges have different counts of numeric cells, Excel returns an error.
Does RSQ work in Excel for the web?
Yes, RSQ is available in Excel for the web, Excel for Windows, Excel for Mac, and Excel mobile apps. The function syntax is the same.
How do I get the correlation coefficient (r) instead of R-squared?
Use the CORREL function: =CORREL(Y_range, X_range). R-squared is the square of that value. Alternatively, take the square root of RSQ and apply the sign of the slope.
Why is my R-squared value 1?
An R-squared of 1 means the data points fall exactly on a straight line (perfect linear fit). This is rare with real data and often indicates only two data points or a calculation error.
Can I calculate R-squared for multiple regression in Excel?
RSQ only handles one independent variable. For multiple regression, use the Regression tool in the Analysis ToolPak, which reports R-squared for the full model.