How to Calculate COVARIANCE in Excel

This guide treats “calculate covariance in excel” the way busy spreadsheet users actually want it: answer first, a live tool to prove it on your own data, then the reasoning. It is written for Excel but calls out every place Google Sheets differs, and the platform toggle at the top switches all shortcuts between Windows and Mac so nothing here assumes the keyboard you are not on.

Exact answer

In Excel: use =COVARIANCE.S(array1, array2) for a sample — it measures whether two variables move together, in units that make the number hard to interpret alone.

On this page8

Syntax

=COVARIANCE.S(array1, array2)

Arguments

Argumentrequired / optionalDescription
array1requiredThe first set of values.
array2requiredThe second set, the same size as array1.

Related functions

CORRELVARSLOPE and INTERCEPT
ƒxCorrelation & TrendlineLive

6 pairs

Correlation (r)
0.9981

R² = 0.9962

Slope
1.9857

Intercept = 0.1667

=CORREL(A2:A10,B2:B10) · =SLOPE(B,A) · =RSQ()
Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

What this does

Covariance measures joint variability: positive when two variables rise together, negative when one rises as the other falls. Its weakness is scale — the result is in the product of the two variables' units, so a covariance of 4,200 means nothing without knowing what is being measured. That is exactly why CORREL exists, dividing covariance by the two standard deviations to produce a bounded -1 to 1 figure. Covariance earns its place in portfolio mathematics, where the covariance matrix, not the correlation matrix, is what combines into portfolio variance. COVARIANCE.S is the sample form; COVARIANCE.P assumes a full population. Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “calculate covariance in excel”. Start on a copy or a tiny sample, keep the affected cells visible, and compare the result with the tool above before you touch the real workbook. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. The point is a calculation you can defend to a CFO or an auditor, but the practical win is that someone else can open the file and understand what happened without asking you.

A worked example

Two return series in B2:B100 and C2:C100: =COVARIANCE.S(B2:B100, C2:C100) returning 0.0032 says they move together, but the size is uninterpretable on its own. Normalising it: =COVARIANCE.S(B,C)/(STDEV.S(B)*STDEV.S(C)) reproduces =CORREL(B,C) exactly, which is the figure to report. Covariance is the quantity portfolio maths runs on, and knowing it is uninterpretable alone is what keeps it out of reports. If there is any chance you will reuse this, drop it into a small template tab right now: a labelled input area on the left and the formula beside it, checked once against the tool above. Next time the same question comes up, the answer is a single paste away instead of a rebuild from memory.

In Google Sheets

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. Treat “calculate covariance in excel” as a small building block rather than a chore. Once the inputs sit in their own cells and the formula reads from them, the same setup answers a dozen related questions with a tweak, and Excel keeps every dependent figure current as the data changes. The tool above is there so you can rehearse and verify before committing anything to a real workbook; the steps and worked example are there so the logic sticks. Get it right once and it stops costing you time — it starts saving it, every time the question comes back around.

Common mistakes

  • Reporting a raw covariance, which is uninterpretable without the units; report the correlation instead.
  • Ranges of different lengths, which returns #N/A.
  • Using COVARIANCE.P on sample data, which understates the figure the same way VAR.P does.

Frequently asked questions

What is the difference between covariance and correlation?

Correlation is covariance divided by both standard deviations, which bounds it between -1 and 1 and makes it comparable across datasets.

Which should I report?

Correlation, nearly always. Covariance is for the maths, not the narrative.

When does covariance matter directly?

Portfolio variance, which combines covariances rather than correlations.

Other ways people ask this

This is also commonly searched as “calculate covariance in excel” and “how to calculate sample covariance in excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.

Why do people search for this in so many different ways?

Because the same task has many names. “calculate covariance in excel”, “how to calculate sample covariance in excel” all point at the one operation explained on this page, which is why they all lead here.