COVARIANCE.P calculates the population covariance between two sets of numbers, showing whether they tend to increase and decrease together. It returns a single number where positive values indicate a positive relationship, negative values indicate an inverse relationship, and zero suggests no linear association.
=COVARIANCE.P(array1, array2)What does COVARIANCE.P do?
COVARIANCE.P is a statistical function in Excel that measures how two variables change together across an entire population. If you have paired data—such as monthly advertising spend and sales, or hours studied and exam scores—COVARIANCE.P tells you whether high values in one variable tend to occur with high values in the other, or with low values. The result is a single number: positive means the variables move in the same direction, negative means they move in opposite directions, and near zero means little linear relationship.
Understanding covariance is useful because it is the foundation for correlation and many financial risk models. While correlation is easier to interpret (it is scaled between -1 and 1), covariance preserves the original units, which can be important when you want to understand the magnitude of co-movement in real terms. For students, it is a core concept in statistics courses; for office workers, it helps answer practical questions like whether two business metrics are linked.
A common real situation: a marketing analyst wants to know if higher ad spending is associated with higher sales across all regions. By entering the two columns into COVARIANCE.P, they get a quick numerical summary of the relationship. This can guide budget decisions or prompt further analysis with correlation or regression.
When to use COVARIANCE.P
- Checking whether two business metrics (e.g., ad spend and revenue) move together across all branches.
- Analysing student performance: do hours of study and test scores covary across the whole class?
- Assessing financial risk: covariance between returns of two stocks in a portfolio.
- Comparing temperature and ice cream sales across all days in a summer.
- Evaluating whether employee training hours and productivity are related across all staff.
- Exploring scientific data: covariance between two measured variables in a complete dataset.
COVARIANCE.P syntax
=COVARIANCE.P(array1, array2)| Argument | Required? | What to enter |
|---|---|---|
array1 | Required | The first range or array of numbers. Must contain at least two numbers and have the same number of data points as array2. Example: A2:A10. |
array2 | Required | The second range or array of numbers. Must be the same size as array1 and contain at least two numbers. Example: B2:B10. |
What it returns: COVARIANCE.P returns a single number: the population covariance between the two arrays. A positive value means the variables tend to increase together; a negative value means one tends to increase as the other decreases; a value near zero indicates no linear relationship.
COVARIANCE.P examples
1 Example 1: Simple Covariance of Study Hours and Scores
This example uses a small dataset of five students to show the basic calculation. The goal is to find the population covariance between hours studied (column A) and exam score (column B). The formula =COVARIANCE.P(A2:A6, B2:B6) compares each pair of values, computes the average product of deviations from the mean, and returns the covariance. A positive result indicates that students who studied more tended to score higher.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Hours Studied | Exam Score | |||
| 2 | 2 | 65 | 40 | ||
| 3 | 4 | 75 | |||
| 4 | 6 | 85 | |||
| 5 | 8 | 95 | |||
| 6 | 10 | 105 | |||
| 7 |
2 Example 2: Covariance of Temperature and Ice Cream Sales
Here we examine daily temperature and ice cream sales over six days. The goal is to see if warmer days are associated with higher sales. The formula =COVARIANCE.P(A2:A7, B2:B7) calculates the population covariance. A positive covariance would confirm that temperature and sales tend to move together. The result is positive, suggesting a positive relationship.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Temperature (°C) | Ice Cream Sales | |||
| 2 | 20 | 100 | 116.6666667 | ||
| 3 | 22 | 120 | |||
| 4 | 24 | 140 | |||
| 5 | 26 | 160 | |||
| 6 | 28 | 180 | |||
| 7 | 30 | 200 | |||
| 8 |
3 Example 3: Covariance of Advertising Spend and Sales Across Regions
A company wants to know if higher advertising spend in a region is associated with higher sales. The table lists ad spend and sales for five regions. The formula =COVARIANCE.P(B2:B6, C2:C6) computes the population covariance between the two columns. A positive result would indicate that regions with higher ad spend tend to have higher sales. The covariance here is positive, supporting that idea.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Ad Spend ($) | Sales ($) | |||
| 2 | North | 1000 | 5000 | 2000000 | ||
| 3 | South | 1500 | 7000 | |||
| 4 | East | 2000 | 9000 | |||
| 5 | West | 2500 | 11000 | |||
| 6 | Central | 3000 | 13000 | |||
| 7 |
4 Example 4: Covariance of Employee Training Hours and Productivity
This example looks at six employees, their training hours, and a productivity score. The goal is to assess whether training hours and productivity covary across the whole team. The formula =COVARIANCE.P(B2:B7, C2:C7) returns the population covariance. A positive value suggests that employees with more training tend to have higher productivity. The result is positive, indicating a positive relationship.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Employee | Training Hours | Productivity Score | |||
| 2 | Alice | 10 | 70 | 29.16666667 | ||
| 3 | Bob | 12 | 75 | |||
| 4 | Carol | 14 | 80 | |||
| 5 | David | 16 | 85 | |||
| 6 | Eve | 18 | 90 | |||
| 7 | Frank | 20 | 95 | |||
| 8 |
5 Example 5: Covariance of Two Stock Returns
An investor holds two stocks and wants to measure how their monthly returns move together over five months. The table shows returns in percentages for Stock A and Stock B. The formula =COVARIANCE.P(B2:B6, C2:C6) calculates the population covariance. A positive covariance means the stocks tend to move in the same direction, which is useful for diversification decisions. The result is positive, indicating some co-movement.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Month | Stock A Return (%) | Stock B Return (%) | |||
| 2 | Jan | 2 | 3 | 8 | ||
| 3 | Feb | 4 | 5 | |||
| 4 | Mar | 6 | 7 | |||
| 5 | Apr | 8 | 9 | |||
| 6 | May | 10 | 11 | |||
| 7 |
Common COVARIANCE.P errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #N/A | The two arrays have a different number of data points. | Ensure both ranges contain the same number of cells. For example, if array1 is A2:A10, array2 should also have 9 cells, such as B2:B10. |
| #VALUE! | One or both arrays contain text or empty cells that cannot be interpreted as numbers. | Remove or replace non-numeric entries. Use numeric values only, or use functions like IFERROR to handle errors. |
| #DIV/0! | One or both arrays contain fewer than two numeric values. | Provide at least two pairs of numbers. Check that your ranges include enough data. |
| #NUM! | The calculation results in a number too large or too small for Excel to handle (rare). | Check for extreme outliers or incorrect data entry that might cause overflow. |
Tips for using COVARIANCE.P
- Use COVARIANCE.P when your data represents the entire population; use COVARIANCE.S for a sample.
- Covariance is scale-dependent: changing units changes the covariance value, so compare covariances only when units are similar.
- To assess the strength of a relationship, calculate the correlation coefficient with CORREL, which is scaled between -1 and 1.
- Ensure both arrays have the same number of data points to avoid errors.
- You can use cell references or array constants, e.g.,
=COVARIANCE.P({1,2,3},{4,5,6}). - Remember that covariance only measures linear relationships; it may be zero even if there is a strong non-linear pattern.
Frequently asked questions
What is the difference between COVARIANCE.P and COVARIANCE.S?
COVARIANCE.P calculates the population covariance, dividing by n. COVARIANCE.S calculates the sample covariance, dividing by n-1. Use .P when your data includes the entire population, and .S when it is a sample.
Can COVARIANCE.P handle text or logical values?
No, COVARIANCE.P ignores text and logical values in references, but if you type them directly into the array arguments, they may cause errors. It's best to use numeric data only.
Why is my COVARIANCE.P result negative?
A negative result means that as one variable increases, the other tends to decrease. This indicates an inverse relationship between the two datasets.
Is covariance the same as correlation?
No. Covariance measures the direction of the linear relationship and depends on the units of the data. Correlation is a standardized version that measures both direction and strength, always between -1 and 1.
What if my arrays have different sizes?
COVARIANCE.P requires both arrays to have the same number of data points. If they differ, Excel returns the #N/A error.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. COVARIANCE.P reference