Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets COVAR Function: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The COVAR function in Google Sheets calculates the population covariance between two data sets, showing how two variables move together. To use it, you need two ranges of numeric data with the same number of values; then type =COVAR(range1, range2) into a cell. That's the short answer. The rest of this guide covers the exact steps, what the result means, common errors, and how to avoid them.

What You'll Need

  • A Google account with access to Google Sheets (free).
  • Two columns or rows of numeric data, each with the same number of entries, with no blank cells or text in the ranges you select.
  • Basic familiarity with entering formulas (starting with an equals sign).

Step-by-Step

  1. Open your spreadsheet. Go to Google Sheets and open the file containing your data, or create a new blank spreadsheet.
  2. Arrange your data. Put the first variable's values in one column (for example, column A) and the second variable's values in another column (for example, column B). Each row should represent one observation. For example, A2:A11 could be hours studied and B2:B11 could be test scores for ten students.
  3. Select an empty cell where you want the covariance to appear, such as C2.
  4. Type the formula. Enter =COVAR(A2:A11, B2:B11) and press Enter. Replace the ranges with your actual data ranges. You can also use =COVAR(A2:A11,B2:B11) without spaces; both work.
  5. Check the result. The cell displays a number. A positive result means the two variables tend to increase together; a negative result means one tends to increase while the other decreases; near zero means little linear relationship. The number is in the units of the two variables multiplied together, so it is not a standardized measure like correlation.
  6. Use the function with whole columns if needed. You can write =COVAR(A:A, B:B) to use entire columns, but this includes the header row if present, which will cause an error. It is safer to use specific ranges that exclude headers.
  7. Copy the formula if you need covariance for other pairs of columns. Adjust the ranges accordingly.

Common Mistakes

  • Unequal range sizes. COVAR requires both ranges to have the same number of cells. If one range has 10 cells and the other has 9, you'll get a #N/A error.
  • Including text or blank cells. The function ignores text and blanks? Actually, COVAR returns an error if any cell in the ranges is text or empty. Make sure both ranges contain only numbers.
  • Confusing COVAR with CORREL. COVAR returns covariance, not correlation. Correlation is standardized between -1 and 1; covariance is not. Use CORREL if you want a standardized measure.
  • Using sample vs. population. Google Sheets' COVAR calculates population covariance (dividing by n). If you need sample covariance (dividing by n-1), use COVAR? Actually, Google Sheets has COVAR for population and COVARIANCE.S? No, Google Sheets does not have COVARIANCE.S; it has COVAR (population) and COVAR? Wait, check: Google Sheets has COVAR (population) and COVAR? Actually, Google Sheets has COVAR and COVARIANCE? Let me verify: In Google Sheets, the functions are COVAR (population covariance) and COVARIANCE? I recall that Google Sheets has COVAR and COVARIANCE.P and COVARIANCE.S? No, that's Excel. Google Sheets has COVAR only for population, and no built-in sample covariance function. To get sample covariance, you can use =COVAR(range1,range2)*n/(n-1) where n is the number of pairs. But be careful: COVAR in Google Sheets actually calculates sample covariance? Let me check: According to Google Sheets documentation, COVAR returns the covariance of a dataset, which is the average of the products of deviations for each data point pair. It uses the population covariance formula (dividing by n). So to get sample covariance, multiply by n/(n-1). This is a common mistake: assuming COVAR gives sample covariance. Clarify in the guide.
  • Not locking ranges when copying. If you copy the formula, relative references may shift. Use absolute references (e.g., $A$2:$A$11) if needed.

Tips

  • Use named ranges to make formulas easier to read: select your data, go to Data > Named ranges, and define a name. Then use =COVAR(StudyHours, TestScores).
  • To quickly check for errors, use the ISNUMBER function or filter your data to ensure all cells are numeric.
  • If you need correlation instead, use =CORREL(range1, range2).
  • Remember that covariance is sensitive to the scale of the data. If you change units (e.g., from hours to minutes), the covariance changes even though the relationship is the same.
  • For a visual check, create a scatter plot (Insert > Chart) to see the relationship before calculating covariance.

Troubleshooting

  • #N/A error: This usually means the ranges are not the same size or contain non-numeric values. Check that both ranges have the same number of cells and that all cells contain numbers (no text, no blanks).
  • #VALUE! error: This can occur if you pass a range that includes an error value or if the arguments are not ranges. Ensure you are referencing cell ranges, not individual cells separated by commas.
  • #DIV/0! error: This happens if one or both ranges are empty or contain only one data point. COVAR requires at least two pairs of numbers? Actually, if there is only one pair, the denominator (n) is 1, so it might not divide by zero, but if n=0? If ranges are empty, you get #DIV/0!. Ensure you have at least two pairs of numeric data.
  • Result seems wrong: Double-check that you are using the correct ranges and that the data is paired correctly (row by row). Also, confirm whether you need population or sample covariance; adjust with multiplication if needed.
  • Formula not calculating: Make sure the cell is not formatted as text. Select the cell, go to Format > Number > Automatic or Number.

Frequently Asked Questions

What is the difference between COVAR and CORREL in Google Sheets?

COVAR returns the covariance, which indicates the direction of the linear relationship but is not standardized. CORREL returns the correlation coefficient, which is standardized between -1 and 1, making it easier to compare across different scales.

Does Google Sheets COVAR calculate sample or population covariance?

COVAR calculates population covariance, dividing by the number of data pairs (n). If you need sample covariance, multiply the result by n/(n-1), where n is the count of pairs.

Can I use COVAR with non-numeric data?

No, COVAR requires numeric data. If any cell in the ranges contains text or is blank, the function returns an error. Ensure both ranges contain only numbers.

Why do I get a #N/A error with COVAR?

The most common cause is that the two ranges do not have the same number of cells. Check that both ranges cover the same number of rows or columns.

Is there a way to calculate covariance for multiple pairs at once?

You can copy the COVAR formula to other cells, adjusting the ranges for each pair. Alternatively, use the COVAR function within an array formula, but that requires careful setup.

Can COVAR handle entire columns like A:A?

Yes, but if the column includes a header row with text, COVAR will return an error. Use specific ranges that exclude headers, such as A2:A100.