Correlation Coefficient in Excel: How to Compute It
In this article
To compute the correlation coefficient in Excel, use the formula =CORREL(array1, array2), where array1 and array2 are the two sets of data you want to compare. This function calculates the Pearson Product-Moment Correlation Coefficient, which measures the strength and direction of a linear relationship between two variables, resulting in a value between -1 and 1.
Calculating a correlation coefficient allows you to determine if two sets of numbers move together. For example, if you are tracking advertising spend and monthly sales, a high positive correlation suggests that as spending increases, sales also tend to increase. Conversely, a negative correlation would indicate that as one variable goes up, the other goes down. Understanding this relationship is fundamental for data analysis, financial forecasting, and scientific research.
What You'll Need
- Microsoft Excel installed on your computer (works across most versions, including Office 365, Excel 2021, 2019, and 2016).
- Two sets of numerical data (quantitative variables) organized into columns or rows.
- Ensured that both data sets contain the same number of data points (pairs).
Step-by-Step
- Organize Your Data: Open your Excel workbook. Place your first variable in one column (e.g., Column A) and your second variable in the adjacent column (e.g., Column B). Ensure that each row represents a single observation. For instance, if Row 2 contains the temperature for Monday in Column A, it must contain the ice cream sales for Monday in Column B.
- Select the Output Cell: Click on an empty cell where you want the correlation coefficient to appear. It is often helpful to label this cell "Correlation" in the cell next to it so you remember what the number represents later.
- Enter the CORREL Function: Type
=CORREL(into the cell. This initiates the function. - Define the First Array: While the parenthesis is open, use your mouse to click and drag to highlight the entire range of the first data set (e.g.,
A2:A50). Alternatively, you can type the range manually. - Add a Comma: Type a comma (
,) to separate the first array from the second. - Define the Second Array: Use your mouse to highlight the entire range of the second data set (e.g.,
B2:B50). Ensure that the range matches the first array exactly; if the first array is 49 cells long, the second must also be 49 cells long. - Close and Execute: Type the closing parenthesis
)and press Enter. - Interpret the Result: Excel will return a decimal value.
- 1.0: A perfect positive linear correlation.
- 0.7 to 0.9: A strong positive correlation.
- 0.4 to 0.6: A moderate positive correlation.
- 0 to 0.3: A weak positive correlation.
- 0: No linear correlation.
- -0.1 to -0.3: A weak negative correlation.
- -0.4 to -0.6: A moderate negative correlation.
- -0.7 to -0.9: A strong negative correlation.
- -1.0: A perfect negative linear correlation.
Common Mistakes
One of the most frequent errors is attempting to calculate correlation with mismatched array sizes. If your first range is A2:A100 and your second range is B2:B99, Excel will return a #N/A error because the function requires pairs of data. Every value in the first set must have a corresponding value in the second set.
Another common mistake is confusing correlation with causation. Just because Excel returns a value of 0.95 does not mean that Variable A caused Variable B to change. It simply means they move in tandem. External factors (confounding variables) could be influencing both, or the relationship could be purely coincidental.
Users also often try to use the CORREL function on non-numerical data. If your cells contain text, currency symbols entered as text, or spaces that Excel interprets as strings, the function may ignore those cells or return an error. Ensure all data is formatted as "Number" or "General" before running the calculation.
Finally, relying solely on the coefficient without looking at a visual representation is a mistake. A correlation coefficient only measures linear relationships. If your data follows a curve (a non-linear relationship), the CORREL function might return a value near 0, even though there is a very clear, predictable relationship between the variables. Always create a scatter plot to verify the nature of the trend.
Tips
To better visualize your correlation, use the Insert > Scatter Chart feature. By plotting your two arrays on an X-Y axis, you can see if the data points form a straight line. If they do, the correlation coefficient is a reliable metric. If they form a U-shape or a wave, the coefficient is misleading.
If you have a massive dataset and want to see correlations between multiple pairs of variables simultaneously, use the Data Analysis Toolpak. To enable it, go to File > Options > Add-ins, select Excel Add-ins from the Manage dropdown, click Go, and check Analysis ToolPak. Once active, you can find the "Correlation" tool under the Data tab in the Data Analysis menu. This generates a correlation matrix, showing every possible pair of variables in your selected range.
For more precision, you can increase the decimal places of your result. Right-click the cell, select Format Cells, choose Number, and set the decimal places to 3 or 4. This is particularly useful when comparing two different pairs of data that both have high correlations (e.g., 0.882 vs 0.891).
Troubleshooting
If your formula returns a #DIV/0! error, it usually means that one of your data sets has zero variance. In other words, all the numbers in one of your columns are identical. Because the correlation formula involves dividing by the standard deviation, and the standard deviation of a constant set of numbers is zero, the math fails. Check your data for columns that contain the same value in every row.
If you see a #VALUE! error, check for non-numeric characters. Even a single cell containing a space, a "N/A" text string, or a hidden character can break the function. Use the Find and Replace (Ctrl + H) tool to locate and remove any non-numeric entries in your data range.
If the result is 0 when you are certain there is a relationship, check for outliers. A single extreme value (a data point far away from the rest) can significantly pull the correlation coefficient toward zero or push it toward 1 or -1, distorting the truth of the general trend. Sort your data or use a scatter plot to identify and investigate these outliers.
If the formula is not updating when you change the data, check your calculation settings. Go to the Formulas tab, click Calculation Options, and ensure that Automatic is selected. If it is set to Manual, you must press F9 to refresh the correlation result.
Frequently Asked Questions
Does the order of the arrays matter?
No. Whether you use =CORREL(A2:A10, B2:B10) or =CORREL(B2:B10, A2:A10), the result will be exactly the same. The correlation between X and Y is identical to the correlation between Y and X.
What is the difference between CORREL and PEARSON functions?
In modern versions of Excel, there is virtually no difference. Both CORREL and PEARSON calculate the Pearson correlation coefficient. However, CORREL is the more widely used and recommended function for general data analysis.
Can I calculate correlation for more than two variables?
The CORREL function only accepts two arrays. To find correlations among three or more variables, you must either create multiple CORREL formulas for each pair or use the Correlation tool in the Data Analysis Toolpak to create a matrix.
How do I handle empty cells in my data?
Excel's CORREL function automatically ignores pairs of cells where one or both cells are empty. However, it only ignores the pair. If cell A5 is empty but B5 has a value, both A5 and B5 are excluded from the calculation to maintain the pairing integrity.
Why is my correlation coefficient 1 or -1?
A result of 1 or -1 indicates a perfect linear relationship. While this is possible in theoretical math, it is rare in real-world data. If you see this, double-check that you aren't accidentally correlating a variable with itself or with a variable that is a direct mathematical transformation of the first (e.g., correlating Celsius temperature with Fahrenheit temperature).