Calculate Correlation in Excel: Step-by-Step Guide
In this article
Yes, you can calculate correlation in Excel, and it is accomplished by using the CORREL function, which returns the Pearson correlation coefficient between two data sets to measure the strength of the relationship. You do not need any external add-ins for the basic calculation; the function is built directly into the software. This guide covers how to input your data correctly, apply the function, and interpret the result, along with troubleshooting common errors that occur when the numbers do not align.
What You'll Need
- A computer running Microsoft Excel (2016, 2019, 2021, or Office 365 are the versions most commonly used; the steps are nearly identical on Mac or Web versions).
- A dataset containing at least two columns of numerical data where you want to find the relationship between the variables.
- A basic understanding of the difference between positive and negative correlation (a score closer to 1 or -1 indicates a strong relationship).
Step-by-Step
- Prepare your data. Organize your data in two distinct columns. For example, place all values for Variable A in Column A (e.g., A2 to A20) and all corresponding values for Variable B in Column B (e.g., B2 to B20). Ensure there are no blank cells in the middle of your data range, as this will cause the function to fail. If a value is missing, either remove it or insert a zero, depending on whether you want to treat the absence of data as a zero value.
- Select the output cell. Click on the empty cell where you want the correlation coefficient to appear. This cell should be separate from your data columns to keep your spreadsheet clean. It is often helpful to place this cell in the same row as your headers or in a dedicated analysis section at the top of the sheet.
- Open the formula dialog. Type an equals sign (
=) to start a formula. Then, typeCORREL. You can either type the function name fully or click the function name from the auto-complete suggestions that appear as you type. Once the name is selected, the formula bar at the top will display the function name with a blinking cursor inside parentheses. - Identify the range for the first array. Click and drag your mouse cursor over the first set of data in the first column. For example, if your data starts in cell A2 and ends in cell A20, you should type
A2:A20into the first set of parentheses. Excel will highlight this range in blue to confirm your selection. - Identify the range for the second array. After typing the comma that separates the arguments in the CORREL function, click and drag your mouse over the second set of data in the adjacent column. If your second data set is in cells B2 through B20, you will type
B2:B20. The complete formula in the bar should now look like=CORREL(A2:A20, B2:B20). - Execute the formula. Press the Enter key on your keyboard to finalize the calculation. The cell you selected in step 2 will now display a single number. This number is the Pearson correlation coefficient, which ranges from -1 to +1.
- Format the result (optional). By default, Excel may display the result as a very long decimal number. If you prefer a cleaner look, right-click the cell containing the result, select Format Cells, and choose Number with 0 decimal places. This rounds the number to the nearest whole value, making it easier to read at a glance.
Interpreting the Result
Understand that the result is a value between -1 and 1. A value of 1 indicates a perfect positive correlation, meaning as one variable increases, the other increases perfectly in a straight line. A value of -1 indicates a perfect negative correlation, meaning as one variable increases, the other decreases perfectly. A value of 0 indicates no correlation; the variables do not have a linear relationship.
Values between these extremes indicate a weaker relationship. For instance, a correlation of 0.8 is considered strong and positive, while a correlation of 0.3 is considered weak and positive. The sign (+ or -) tells you the direction of the relationship.
Common Mistakes
- Non-numeric data. One of the most frequent errors is including text, labels, or blank spaces in the selected range. Excel cannot calculate a correlation for text. Always ensure that the cells you are referencing contain only numbers (including dates, which Excel treats as numbers).
- Mismatched ranges. Ensure that the number of data points in your first range matches the number in your second range. If you select A2:A20 but accidentally select B2:B19, Excel will return an error because it cannot pair the 20th item in the first list with a missing item in the second list.
- Confusing correlation with causation. A high correlation does not mean that one variable causes the other. It only means they move together. For example, ice cream sales and drowning incidents have a high positive correlation, but eating ice cream does not cause drowning; the third variable (hot weather) causes both.
- Outliers skewing the data. A single extreme outlier can drastically change the correlation coefficient. If you suspect your data has outliers, you may need to clean your data set before calculating the correlation.
Tips
- Use the Data Analysis Toolpak. If you need to calculate correlations for many variables at once, do not use the CORREL function repeatedly. Instead, go to the Data tab on the ribbon, click Data Analysis (usually in the far right), and select Correlation. This allows you to select an entire matrix of data, and Excel will generate a correlation table for every pair of columns simultaneously.
- Visualize the data. Before calculating, create a scatter plot to visually inspect the relationship. Use the Insert tab, select Scatter, and choose the chart type that plots points without lines. This helps confirm that the relationship is linear before you commit to the numerical calculation.
- Check for linearity. The Pearson correlation coefficient only measures linear relationships. If your data follows a curved pattern (like a parabola), the CORREL function will return a value near zero, even though there is a strong relationship, just not a linear one.
Troubleshooting
If your calculation returns an error or a result that does not make sense, follow these steps to identify the issue.
#VALUE! Error
If you see #VALUE! in the cell, it means one or more of the cells in your selected range contain non-numeric data. Check your data columns to ensure there are no text labels (like "Variable A" or "Price") inside the number ranges. Select the range you are referencing in the formula and look at the bottom-right corner of the Excel window; if it says "Count: 0", your range is likely empty or contains only text.
#N/A Error
The #N/A error typically appears when the two data arrays contain a different number of data points. For example, if your first array has 10 numbers and your second array has 9, Excel cannot perform the pairwise calculation. Highlight the second range in your formula and ensure it matches the length of the first range exactly.
Unexpected Result (e.g., 0.0)
If the result is 0.0, it means the data sets do not have a linear relationship. Before concluding there is no relationship, ensure that you are not looking at a non-linear relationship. Create a scatter plot of the data to see if the points follow a curve. If they do, the Pearson correlation will not capture that relationship accurately, and you may need a different statistical method.
Formula Not Updating
If you add new data to your spreadsheet but the correlation coefficient does not update automatically, ensure that your formula is referencing the correct absolute range. If you dragged the formula down a column, it might have adjusted the cell references. Click on the formula cell and verify that the range (e.g., A2:A20) is still correct. If it has changed, re-select the full range to lock it in.
Frequently Asked Questions
What is the difference between covariance and correlation?
Covariance measures how much two variables change together, but it is not scaled, meaning the units depend on the units of the variables. Correlation is a normalized version of covariance that is always between -1 and 1, making it easier to interpret and compare across different datasets.
Can I calculate correlation for more than two columns at once?
Yes. You can use the Data Analysis Toolpak method mentioned in the tips section. Selecting multiple columns in the Correlation tool generates a matrix where the intersection of two columns shows their correlation coefficient.
Does Excel calculate Spearman or Kendall correlation?
The standard CORREL function in Excel is specifically for Pearson correlation. To calculate Spearman or Kendall rank correlation, you must use the CORREL function on the ranked data (you can rank data using the RANK.EQ function) or use the Analysis ToolPak's Rank and Percentile tool first.
Why is my correlation negative if both variables increase?
A negative correlation means that as one variable increases, the other decreases. If both variables are increasing, you would expect a positive correlation. A negative result suggests an inverse relationship, such as temperature and heating bills (as temperature drops, bills rise).
Is a correlation of 0.5 strong?
It depends on the field of study, but generally, a correlation of 0.5 is considered a moderate to strong positive relationship. It indicates a fairly predictable relationship, but there is still a significant amount of variability in the data that is not explained by the relationship.