Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets Pearson Correlation: Guide and Examples

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To calculate the Pearson correlation coefficient in Google Sheets, use the formula =CORREL(data_y, data_x). This function measures the linear relationship between two sets of numbers, returning a value between -1 and 1 that indicates how strongly the variables move together. A value of 1 means a perfect positive correlation, -1 means a perfect negative correlation, and 0 means no linear relationship exists.

What You'll Need

  • A Google account with access to Google Sheets.
  • Two columns of numerical data of equal length.
  • Clean data sets (no text, symbols, or empty cells within the range you intend to analyze).

Step-by-Step

  1. Organize Your Data: Open your Google Sheet and ensure your data is arranged in two adjacent columns. For example, place your first variable (Independent Variable) in Column A and your second variable (Dependent Variable) in Column B. Ensure that each row represents a single observation; for instance, if you are tracking temperature and ice cream sales, Row 2 should contain the temperature and sales for the same day.
  2. Select the Output Cell: Click on an empty cell where you want the correlation coefficient to appear. It is usually best to place this below your data or in a separate summary table to avoid cluttering your workspace.
  3. Enter the Formula: Type =CORREL( into the cell. The CORREL function requires two arguments: the first range of cells and the second range of cells.
  4. Define the First Range: While the cursor is still inside the parentheses, click and drag to highlight the first column of data (e.g., A2:A50). Alternatively, you can type the range manually.
  5. Insert the Comma: Type a comma to separate the two data ranges.
  6. Define the Second Range: Click and drag to highlight the second column of data (e.g., B2:B50). It is critical that this range is exactly the same size as the first range.
  7. Complete and Execute: Type the closing parenthesis ) and press Enter. Google Sheets will instantly calculate the Pearson correlation coefficient.
  8. Interpret the Result: Look at the decimal value produced. If the number is close to 1 (e.g., 0.85), there is a strong positive correlation. If it is close to -1 (e.g., -0.90), there is a strong negative correlation. If the result is near 0 (e.g., 0.05), there is little to no linear relationship between the variables.

Common Mistakes

One of the most frequent errors is using mismatched range sizes. If your first range is A2:A50 (49 cells) and your second range is B2:B51 (50 cells), Google Sheets will return a #N/A error. The Pearson function requires a one-to-one pairing for every data point; it cannot calculate a relationship if one variable has more observations than the other.

Another common mistake is attempting to use the CORREL function on non-numerical data. If your columns contain text, currency symbols typed as text, or dates formatted incorrectly, the function may ignore those cells or return an error. Ensure all cells in your selected range are formatted as numbers.

Users often confuse correlation with causation. A high Pearson coefficient proves that two variables move together, but it does not prove that one variable causes the other to change. For example, ice cream sales and sunburns are highly correlated because both increase during hot weather, but eating ice cream does not cause sunburns.

Finally, some users mistakenly apply the CORREL function to data that has a non-linear relationship. The Pearson correlation only detects linear (straight-line) relationships. If your data forms a curve (like a U-shape), the Pearson coefficient might be near zero even though there is a very clear mathematical relationship between the variables.

Tips

To better visualize the correlation you just calculated, create a Scatter Plot. Highlight both columns of data, go to Insert > Chart, and select "Scatter chart" from the chart editor. If the dots roughly form a straight line sloping upward, you have a positive correlation. If they slope downward, it is a negative correlation. If they look like a random cloud, there is no correlation.

For more advanced analysis, you can add a Trendline to your scatter plot. In the Chart Editor, go to Customize > Series and check the "Trendline" box. You can also check "Show R²" (the coefficient of determination). The R² value is simply the square of the Pearson correlation coefficient and tells you what percentage of the variance in one variable is explained by the other.

If you have a massive dataset and want to check correlations between multiple different columns, consider creating a correlation matrix. This involves setting up a grid where both the rows and columns are your variable names, and each intersecting cell contains a CORREL formula comparing those two specific variables.

Use the =ROUND() function to make your results more readable. Instead of a long decimal like 0.84729384, use =ROUND(CORREL(A2:A50, B2:B50), 2) to limit the result to two decimal places (e.g., 0.85).

Troubleshooting

If you encounter a #DIV/0! error, it usually means that one of your data ranges has a standard deviation of zero. In plain English, this means every single number in one of your columns is identical. Since the Pearson formula involves dividing by the standard deviation, if there is no variation in the data, the math becomes impossible, resulting in a division-by-zero error.

If you see a #N/A error, double-check your range dimensions. Ensure that the start and end row numbers are identical for both ranges. For example, if you used A2:A100, you must use B2:B100. Even a single cell difference will trigger this error.

If the result seems wildly inaccurate, check for outliers. Pearson correlation is extremely sensitive to extreme values. A single data point that is far removed from the rest of the set can pull the correlation coefficient significantly higher or lower than it should be. Inspect your data for typing errors (e.g., typing 1000 instead of 10) that might be skewing the result.

If the formula is not calculating at all and simply appearing as text in the cell, check that you started the cell with an equals sign (=). Also, ensure the cell is not formatted as "Plain Text" via the Format > Number menu; if it is, change it to "Automatic" and re-enter the formula.

Frequently Asked Questions

What is the difference between CORREL and RSQ?

CORREL returns the Pearson correlation coefficient (r), which ranges from -1 to 1 and shows the direction of the relationship. RSQ returns the square of that value (r²), which ranges from 0 to 1 and shows the strength of the relationship without indicating direction.

Can I use CORREL with more than two columns?

No, the CORREL function only accepts two ranges. To find the correlation between three or more variables, you must run separate CORREL functions for each pair of variables you wish to compare.

Does the order of the ranges matter?

No. Whether you use =CORREL(RangeA, RangeB) or =CORREL(RangeB, RangeA), the result will be exactly the same because the relationship between the two variables is mutual.

What happens if there are empty cells in my range?

Google Sheets ignores pairs of cells where one or both cells are empty. However, if you have a number in Column A but a blank in Column B for the same row, that specific pair is excluded from the calculation, which may reduce your sample size.

Is Pearson correlation the only way to measure relationship in Sheets?

Pearson is the most common for linear relationships. While Google Sheets doesn't have a built-in Spearman's Rank correlation function, you can achieve it by using the =RANK() function on your data first and then applying =CORREL() to those ranks.