Stats Assistance
Guide

How to Calculate a Correlation Coefficient in Excel

The formula is =CORREL(array1, array2). Everything below covers what that leaves out: the p value, the confidence interval, Spearman, and the correlation matrix.

The short answer

Put one variable in a column, the other in the column beside it, and enter:

=CORREL(A2:A13, B2:B13)

That returns Pearson's r, a number from -1 to +1. =PEARSON(A2:A13, B2:B13) returns the identical value. Excel keeps both for historical reasons.

Step by step with real numbers

Twelve students, hours studied against exam score.

RowA: HoursB: Score
2257
3369
4456
5563
6650
7775
8871
9981
101069
111176
121280
131377
  1. Type the headers in row 1: Hours in A1, Score in B1.
  2. Enter the twelve pairs in rows 2 through 13.
  3. In any empty cell, enter =CORREL(A2:A13, B2:B13).
  4. Excel returns 0.72.

For the proportion of shared variance, use =RSQ(B2:B13, A2:A13), which gives 0.52. Note the argument order: RSQ takes the y values first, the opposite of CORREL's symmetry. Squaring the CORREL result gets you to the same place.

Excel does not give you a p value

This is the gap that matters. CORREL, PEARSON, and the Analysis ToolPak all hand back a coefficient and stop. An r of .72 from twelve students and an r of .72 from twelve hundred are not the same finding, and Excel shows you the same number for both.

Two extra cells close it. With r in cell D1 and n = 12:

D2:  =D1*SQRT(12-2)/SQRT(1-D1^2)
D3:  =T.DIST.2T(ABS(D2), 12-2)

D2 is the t statistic, 3.28. D3 is the two-tailed p value, 0.008. So the correlation is significant at the .05 level, and now you can report it.

On Excel 2007 and earlier, the function is =TDIST(ABS(D2), 10, 2) instead.

Excel does not give you a confidence interval either

The interval requires a Fisher z transformation, an inverse normal, and a transformation back. It is four more cells of arithmetic and easy to get subtly wrong.

For the data above the 95% interval runs from .25 to .92. Worth seeing. An r of .72 sounds settled until the interval shows the population value could plausibly be .25. Twelve students do not pin down much, and the coefficient alone hides that.

Skip the extra cells. Paste the same two columns into the correlation calculator and get r, r², the exact p value, the confidence interval, and an APA 7 write-up in one step.

Open the correlation calculator

Spearman's rank correlation in Excel

Excel has no Spearman function. Rank each variable first, then correlate the ranks.

  1. In C2: =RANK.AVG(A2, $A$2:$A$13, 1) and fill down.
  2. In D2: =RANK.AVG(B2, $B$2:$B$13, 1) and fill down.
  3. Then =CORREL(C2:C13, D2:D13), which returns 0.75 for this data.

Use RANK.AVG, not RANK.EQ. Spearman requires tied values to share the average of the ranks they span. RANK.EQ assigns them all the lowest rank in the tie and leaves gaps, which shifts the coefficient whenever ties exist. With no ties the two agree, which is how the mistake survives unnoticed until it matters.

Building a correlation matrix in Excel

For more than two variables, the Analysis ToolPak does it in one pass.

  1. Enable the add-in once. Windows: File, Options, Add-ins, Manage Excel Add-ins, Go, tick Analysis ToolPak. Mac: Tools, Excel Add-ins, tick Analysis ToolPak.
  2. Data tab, Data Analysis, Correlation.
  3. Set Input Range to the whole block of variables including headers, set Grouped By to Columns, tick Labels in first row.
  4. Choose an output cell and confirm.

Excel returns a lower triangle of Pearson coefficients. No p values, no sample sizes, no significance markers, and no option for Spearman. For a matrix you intend to publish, that means adding every p value by hand, once per pair, which is where transcription errors get in.

Where CORREL quietly misleads

Related

Doing this on a Mac more than once? ReliCheck Quanta builds full correlation matrices with p values, significance markers, scatterplots, and APA tables from your raw data. Free to try.

Get Quanta