Correlation Test in Excel: Step-by-Step
In this article
Yes, you can run a correlation test in Excel using the built-in CORREL function or the Analysis ToolPak add-in. The CORREL function gives you the correlation coefficient (r) between two data sets, while the Data Analysis ToolPak provides a fuller output including the p-value, which tells you whether the correlation is statistically significant. This guide covers both methods, plus how to interpret the results and avoid common pitfalls.
What You'll Need
- Microsoft Excel (2016 or later for the CORREL function; the Analysis ToolPak is available in most desktop versions).
- Two columns of numeric data, side by side, with no blank cells in the range. Each row should represent a paired observation (e.g., height and weight for the same person).
- If you want a p-value, you'll need the Analysis ToolPak add-in enabled. Check by going to the Data tab and looking for "Data Analysis" on the far right. If it's not there, enable it via File > Options > Add-ins > Manage Excel Add-ins > Go, then tick "Analysis ToolPak" and click OK.
Step-by-Step
Method 1: Using the CORREL Function (Quick Coefficient)
- Open your Excel workbook and ensure your two data columns are adjacent (e.g., Column A and Column B). Each row must be a paired observation.
- Click an empty cell where you want the correlation coefficient to appear.
- Type
=CORREL(then select the first data range (e.g.,A2:A20), type a comma, select the second range (e.g.,B2:B20), and close the parenthesis:=CORREL(A2:A20, B2:B20). - Press Enter. The cell shows the correlation coefficient r, a number between -1 and 1. Positive means both variables move together; negative means they move in opposite directions; near 0 means no linear relationship.
Method 2: Using the Analysis ToolPak (Coefficient + P-Value)
- Make sure the Analysis ToolPak is enabled (see What You'll Need).
- Go to the Data tab and click "Data Analysis" (usually far right). If you don't see it, the add-in isn't enabled.
- In the dialog box, scroll down and select "Correlation", then click OK.
- In the "Input Range" field, select both columns of data including the header row if you have one. For example, if your data is in A1:B20 with headers in row 1, select
$A$1:$B$20. - Check the "Labels in first row" box if you included headers. This ensures Excel treats the first row as labels, not data.
- Choose an output option: "Output Range" lets you pick a cell where the table will start; "New Worksheet Ply" creates a new sheet with the result. Click OK.
- Excel produces a table showing the correlation coefficient between each pair of variables. For two columns, you'll see a 2x2 matrix with 1s on the diagonal and the correlation coefficient in the off-diagonal cell. Note: this output does not include a p-value.
Getting a P-Value (Statistical Significance)
- The ToolPak's Correlation tool does not give a p-value. To get one, you need to use the t-distribution. First, calculate the t-statistic using the formula:
t = r * SQRT((n-2)/(1-r^2))where r is your correlation coefficient and n is the number of paired observations. - In Excel, type this formula in a cell, replacing r with the cell reference containing your correlation coefficient and n with your sample size. For example, if r is in C2 and n=20, type:
=C2*SQRT((20-2)/(1-C2^2)). - To get the two-tailed p-value, use the T.DIST.2T function:
=T.DIST.2T(ABS(t_value), n-2). Replace t_value with the cell reference of your t-statistic and n-2 with your degrees of freedom. For example, if t is in D2 and n=20:=T.DIST.2T(ABS(D2), 18). - The result is the p-value. If it's less than 0.05, the correlation is statistically significant at the 5% level.
Common Mistakes
- Including non-numeric data: The CORREL function ignores text and blank cells, but the ToolPak may treat them as errors. Ensure your ranges contain only numbers.
- Mismatched row pairs: Each row must represent the same subject or observation. If rows are misaligned, the correlation will be meaningless.
- Confusing correlation with causation: A high correlation does not mean one variable causes the other. Always consider lurking variables.
- Ignoring outliers: A single extreme value can drastically inflate or deflate the correlation coefficient. Always plot your data first to spot outliers.
- Using the wrong output: The ToolPak's Correlation tool does not give a p-value; you must calculate it separately. Many users mistakenly think the output includes significance.
- Forgetting to enable the ToolPak: If you don't see "Data Analysis" in the Data tab, the add-in is off. Enable it before starting.
Tips
- Always visualize first: Create a scatter plot (Insert > Chart > Scatter) to see the relationship. Correlation only measures linear relationships; a curved pattern may have a low r even if the variables are strongly related.
- Use absolute references: When copying formulas, use $ signs (e.g.,
$A$2:$A$20) to prevent ranges from shifting. - Check your data for normality: The p-value calculation assumes both variables are approximately normally distributed. If they're not, consider Spearman's rank correlation (use the RANK function or the ToolPak's "Rank and Percentile" tool).
- Interpret r in context: r = 0.8 is strong, but r = 0.2 may be meaningful in some fields. Always consider the domain.
- Use the CORREL function for quick checks: It's fast and doesn't require the add-in. Use the ToolPak only when you need a formal output table.
Troubleshooting
- #DIV/0! error: This happens when the denominator is zero, usually because one of the data ranges has zero variance (all values identical). Check for constant columns.
- #VALUE! error: The CORREL function is picking up text or non-numeric entries. Check for cells with spaces or text.
- "Data Analysis" not visible: Enable the add-in via File > Options > Add-ins > Manage Excel Add-ins > Go, then tick "Analysis ToolPak". If you're on a Mac, go to Tools > Add-ins.
- ToolPak output looks wrong: If the correlation matrix shows 1s on the diagonal but the off-diagonal cell seems off, check that you selected the correct input range. Also verify that "Labels in first row" is checked only if you have headers.
- P-value formula returns #NUM!: This occurs if the t-statistic is negative and you used T.DIST.2T without ABS. Always wrap the t-value in ABS() as shown.
- Correlation coefficient seems too high or low: Re-check your data for outliers. Use a scatter plot to see if one point is pulling the line.
Frequently Asked Questions
Can I run a correlation test in Excel Online?
Excel Online supports the CORREL function, but the Analysis ToolPak is not available in the browser version. For a p-value, you'd need to calculate it manually using the t-distribution formulas, which work in Excel Online.
What is the difference between CORREL and PEARSON?
They are identical. The PEARSON function is kept for compatibility with older versions; both return the Pearson correlation coefficient.
How do I interpret a negative correlation?
A negative r (e.g., -0.6) means that as one variable increases, the other tends to decrease. The strength is the absolute value: -0.6 is as strong as +0.6. The sign only indicates direction.
Can I correlate more than two columns at once?
Yes, the ToolPak's Correlation tool accepts multiple columns and produces a full correlation matrix. The CORREL function only works with two ranges, but you can run it multiple times.
What does a p-value of 0.05 mean exactly?
It means that if there were truly no correlation in the population, you'd see a correlation this extreme only 5% of the time by chance. It's a common threshold for statistical significance, but it's arbitrary.
My data has missing values. What should I do?
The CORREL function ignores rows with missing values, but the ToolPak may error. You can either delete rows with missing data or use the CORREL function and note that the sample size is reduced.