Statistical function

COVARIANCE.P function

Returns the population covariance of two data sets: the average product of their deviations from their means.

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.P(array1, array2)
ArgumentWhat it means
array1RequiredThe first range of numbers.
array2RequiredThe second range, with the same number of values.

Returns: A number whose sign shows the direction of the relationship (positive = move together, negative = move opposite).

How COVARIANCE.P works

Covariance tells you whether two variables tend to move in the same direction. For each pair it multiplies how far the first value is from its mean by how far the second is from its mean, then averages those products. If above-average values of one tend to come with above-average values of the other, the products are mostly positive and so is the covariance.

Unlike CORREL, covariance keeps the units of the data (for example "percent × percent"), so its size is hard to judge on its own; it is mainly a building block for portfolio risk, regression and correlation. The .P version divides by n and treats your data as the whole population. If the data are a sample used to estimate a larger group, use COVARIANCE.S, which divides by n − 1. COVARIANCE.P replaced the older COVAR.

Examples

1Do two stocks move together?

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

Result: 2.7061

The covariance of the monthly returns is 2.7061 (in %², formatted to 4 decimal places). The positive sign means the stocks tend to rise and fall together, which matters for diversification. The correlation of the same data is 0.9679.

2Covariance with itself is the variance

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

Result: 2.5556

Pairing a column with itself gives its population variance, the same as =VAR.P(B2:B7): 2.5556. Portfolio models use exactly these variances and covariances.

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

Common errors and how to fix them

ErrorWhy it happensFix
#N/AThe two ranges contain different numbers of values.Make the ranges the same size.
#DIV/0!Either range is empty.Check the references.

Tips

  • Divide covariance by the product of the two population standard deviations to get the correlation: =COVARIANCE.P(B2:B7,C2:C7)/(STDEV.P(B2:B7)*STDEV.P(C2:C7)).

Google Sheets

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

COVARIANCE.P 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.P
DutchCOVARIANTIE.P
FinnishKOVARIANSSI.P
FrenchCOVARIANCE.PEARSON
GermanKOVARIANZ.P
HungarianKOVARIANCIA.S
ItalianCOVARIANZA.P
Norwegian (Bokmål)KOVARIANS.P
PolishKOWARIANCJA.POPUL
Portuguese (Brazil)COVARIAÇÃO.P
Portuguese (Portugal)COVARIÂNCIA.P
RussianКОВАРИАЦИЯ.Г
SwedishKOVARIANS.P
TurkishKOVARYANS.P