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)| Argument | What it means | |
|---|---|---|
array1 | Required | The first range of numbers. |
array2 | Required | The 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?
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Month | Stock A % | Stock B % | ||
| 2 | Jan | 2.1 | 1.5 | 2.7061 | |
| 3 | Feb | -1.3 | -2 | ||
| 4 | Mar | 3.4 | 2.8 | ||
| 5 | Apr | 0.8 | 1.1 | ||
| 6 | May | -0.5 | -1.2 | ||
| 7 | Jun | 1.9 | 2.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
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Month | Stock A % | Stock B % | ||
| 2 | Jan | 2.1 | 1.5 | 2.5556 | |
| 3 | Feb | -1.3 | -2 | ||
| 4 | Mar | 3.4 | 2.8 | ||
| 5 | Apr | 0.8 | 1.1 | ||
| 6 | May | -0.5 | -1.2 | ||
| 7 | Jun | 1.9 | 2.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.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | The 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.
| Language | Function name |
|---|---|
| Danish | KOVARIANS.P |
| Dutch | COVARIANTIE.P |
| Finnish | KOVARIANSSI.P |
| French | COVARIANCE.PEARSON |
| German | KOVARIANZ.P |
| Hungarian | KOVARIANCIA.S |
| Italian | COVARIANZA.P |
| Norwegian (Bokmål) | KOVARIANS.P |
| Polish | KOWARIANCJA.POPUL |
| Portuguese (Brazil) | COVARIAÇÃO.P |
| Portuguese (Portugal) | COVARIÂNCIA.P |
| Russian | КОВАРИАЦИЯ.Г |
| Swedish | KOVARIANS.P |
| Turkish | KOVARYANS.P |