How to Calculate Variance in Excel: Step by Step
In this article
To calculate variance in Excel, pick the function that matches your data: use =VAR.S(range) for a sample of data and =VAR.P(range) for a full population. Type the formula into an empty cell, replace range with your actual cells (for example A2:A20), and press Enter. That single formula returns the variance. The rest of this guide covers the difference between the two functions, how to set up the data so the result is trustworthy, and how to fix the errors that show up most often.
What You'll Need
- A spreadsheet in Excel with a column or row of numeric values (desktop Excel for Windows or Mac, Excel for the web, or the mobile app all include these functions).
- Your data organised so one variable per column, one observation per row, with an empty header cell for a label.
- A clear decision on whether your numbers are a sample or the whole population, because that changes which function you use.
Step-by-Step
- Lay out the data cleanly. Put your numbers in a single contiguous range such as
A2:A31. Remove blanks, text notes and merged cells from that range. Variance functions ignore empty cells and text, so a stray label or a blank row in the middle can quietly shrink the number of values used and change the answer. - Decide sample versus population. A sample is a subset, such as ten months of sales from a store that has been open for years, or survey results from part of a group. A population is every value you care about, such as all twelve monthly totals for a single calendar year. Use the sample function for a subset and the population function for the complete set.
- Choose a cell for the result. Click an empty cell away from your data, for instance
C1. Avoid typing the formula inside the data range itself. - Enter the sample variance formula. Type
=VAR.S(A2:A31)and press Enter. In older workbooks created before `VAR.S` existed, the legacy functionVAR(A2:A31)still works and returns the same sample variance. - Or enter the population formula. For a complete set of values, type
=VAR.P(A2:A31)instead. The legacy equivalent isVARP(A2:A31). The population result is always smaller than the sample result on the same data. - Confirm the right range was captured. Click the cell with the formula. In the formula bar, look at the range and check that it covers the first and last data points. A range that stops one row early is the single most common cause of a wrong answer.
- Check the answer against the square root. Variance is in squared units, so it can look huge. Type
=SQRT(C1)in another cell to get the standard deviation, the same spread expressed in your original units. If the standard deviation looks sensible next to your data, the variance is almost certainly right. - Add a label. Put text in the cell beside the result, such as "Sample variance" or "Population variance", so anyone reading the sheet knows which one they are looking at. The two numbers differ, and mixing them up is easy to do later.
- Copy the formula down a column if needed. To compute variance for several groups, use absolute references so the ranges do not shift wrongly, for example
=VAR.S($B$2:$B$31), then drag the fill handle down. - Format the result for readability. Select the result cell and use Home > Number to set the number of decimal places. Variance often comes out with many digits; two or three decimals is usually enough for a report.
Common Mistakes
Using the wrong function. `VAR.S` on a population, or `VAR.P` on a sample, gives a systematically wrong figure. The population version divides the squared deviations by the count of values; the sample version divides by count minus one, which corrects for the fact that a sample rarely includes the extremes of the whole group. When in doubt about your data, state which function you used next to the result.
Letting text or blanks hide in the range. Excel skips text, logical values and empty cells when the range is selected as a reference. If your column contains a dash, an N/A marker or a spacer row, the count silently drops and the variance changes without any error appearing.
Including the header cell. A header such as "Sales" is text and gets ignored, so the answer is usually unaffected, but the range looks wrong to anyone auditing the sheet. Start at the first numeric cell.
Confusing variance with standard deviation. Variance is the average of the squared differences from the mean, so its units are squared. If someone expects a spread in the same units as the data, they want the standard deviation, not the variance.
Assuming a single large value is an error. Variance is highly sensitive to outliers because each deviation is squared. One unusually high reading can dominate the result. Check whether that value is genuine before deleting it.
Typing numbers as text. Values pasted from another system can carry a leading apostrophe or a stray space and be stored as text. They are then ignored by the formula. Watch for numbers that sit on the left side of the cell instead of the right.
Tips
Use =VAR.S and =VAR.P rather than the legacy `VAR` and `VARP` functions; the newer names make the sheet self-documenting and are what Excel's formula autocomplete offers first. Function names and menu labels can differ slightly between versions, languages and platforms, so if a name is not recognised, start typing =VAR and pick from the list Excel shows.
For quick exploration, select a range and look at the status bar at the bottom of the window; Excel shows the count, sum and average there, which is a fast sanity check on how many values the formula will actually see.
Keep the raw data and the variance calculation on separate sheets if the workbook is shared, so sorting the data does not break the ranges. Structured references in an Excel table (created with Insert > Table) make this cleaner, because the formula can point at a whole column by name and expands automatically as rows are added.
Report the sample size alongside the variance. A variance from four values means something very different from a variance from four hundred, and readers will want the count to judge it.
If you need variance for weighted data or for several variables at once, Excel's Data Analysis ToolPak (enabled from the add-ins dialog in the developer or add-ins section of the options) provides a descriptive statistics report, though it is not available in every version, including some web and mobile versions. The plain functions above work everywhere.
Troubleshooting
A #DIV/0! error. This appears when the range contains fewer than two numeric values for `VAR.S`, because the divisor is count minus one. Check for blanks, text or a range that points at the wrong cells.
A #VALUE! error. Usually the range contains something Excel cannot treat as a number, or the argument was typed directly rather than as a reference. Verify the range and remove stray characters.
A #NAME? error. The function name was misspelled, or the version of Excel does not recognise it. Try =VAR( from the autocomplete list and see which variants appear.
The result looks far too large. Confirm you did not use the population function where a sample was expected, and check for one outlier dragging the squared deviations upward. Sort the column to see the extremes.
The result is zero. Either every value is identical, or the range is pointing at blank or single-value cells. A zero variance is correct only when all values are the same.
The formula will not update after you change data. Calculation may be set to manual. Check the calculation options in the Formulas section of the ribbon or options, set them back to automatic, and press F9 to recalculate.
Frequently Asked Questions
What is the difference between VAR.S and VAR.P?
VAR.S estimates variance from a sample and divides by the number of values minus one. VAR.P calculates the variance of an entire population and divides by the number of values. On the same data, VAR.P always returns the smaller number.
Can I calculate variance across non-adjacent cells?
Yes. Separate the references with commas, for example =VAR.S(A2,A5,A9,A14). This is useful for scattered values but easy to get wrong, so list them carefully.
Does variance work on filtered or hidden rows?
The variance functions include hidden rows and rows hidden by a filter. If you need a result from visible rows only, copy the filtered values to a new range first, since there is no variance equivalent of the visible-only aggregate functions.
How do I show variance as a percentage?
Divide the variance by the mean, or use the coefficient of variation: the standard deviation divided by the mean. Format the cell as a percentage from Home > Number. Plain variance itself is in squared units, not a percentage.
Is variance available in Excel for the web and mobile?
Yes, VAR.S and VAR.P work in Excel for the web and the mobile apps. The Data Analysis ToolPak is not available in all versions, so use the plain functions if you need a method that works everywhere.