Statistical function

COVARIANCE.S function

Returns the sample covariance of two data sets (dividing by n − 1), used when your data are a sample from a larger population.

Available in Excel 2010 and later, Microsoft 365, Excel for the web, Excel for Mac 2011 and later

Excel 2010 and laterWorks in Google Sheets

Syntax

COVARIANCE.S(array1, array2)
ArgumentWhat it means
array1RequiredThe first range of numbers.
array2RequiredThe second range, with the same number of values.

Returns: A number: positive if the variables tend to move together, negative if they move in opposite directions.

How COVARIANCE.S works

COVARIANCE.S measures how two variables move together, exactly like COVARIANCE.P, except that it divides the sum of products by n − 1 instead of n. That small change corrects the tendency of a sample to understate the spread of the population it came from, the same reason STDEV.S divides by n − 1.

Use the .S version when your rows are a sample: six months out of many years of trading, 40 customers out of thousands. Use .P only when you truly have every member of the group. For small samples the difference is noticeable (here n/(n−1) = 6/5, so the sample result is 20% larger); for large samples it disappears.

Examples

1Sample covariance of stock returns

E2fx=COVARIANCE.S(B2:B7, C2:C7)
ABCDE
1MonthStock A %Stock B %
2Jan2.11.53.2473
3Feb-1.3-2
4Mar3.42.8
5Apr0.81.1
6May-0.5-1.2
7Jun1.92.2

Result: 3.2473

Six months are only a sample of the stocks' history, so the sample covariance 3.2473 is the better estimate (formatted to 4 decimal places). It equals the population figure 2.7061 × 6/5.

2Advertising spend and sales

E2fx=COVARIANCE.S(B2:B7, C2:C7)
ABCDE
1MonthAd spend (k€)Sales (k€)
2Jan24111.4000
3Feb3.558
4Mar1.544
5Apr456
6May353
7Jun566

Result: 11.4000

The covariance is 11.4000 (k€ × k€). Dividing it by the variance of ad spend gives the slope of the best-fit line, about 6.84 k€ of sales per extra 1 k€ of advertising, the same as =SLOPE(C2:C7, B2:B7).

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/AThe ranges contain different numbers of values.Use ranges of equal size.
#DIV/0!There are fewer than two pairs of values.Covariance needs at least two observations.

Tips

  • Covariance depends on units: measuring sales in euros instead of thousands multiplies it by 1,000. Use CORREL when you need a unit-free measure.

Google Sheets

COVARIANCE.S also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

COVARIANCE.S in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishKOVARIANS.S
DutchCOVARIANTIE.S
FinnishKOVARIANSSI.S
FrenchCOVARIANCE.STANDARD
GermanKOVARIANZ.S
HungarianKOVARIANCIA.M
ItalianCOVARIANZA.C
Norwegian (Bokmål)KOVARIANS.S
PolishKOWARIANCJA.PRÓBKI
Portuguese (Brazil)COVARIAÇÃO.S
Portuguese (Portugal)COVARIÂNCIA.S
RussianКОВАРИАЦИЯ.В
SpanishCOVARIANZA.M
SwedishKOVARIANS.S
TurkishKOVARYANS.S