Excel guide · 4 min read
How to calculate variance in Excel
=VAR.S(B2:B11) when your numbers are a sample from something bigger, which is most of the time. Use =VAR.P(B2:B11) only when the range holds every value you care about. Variance is the average squared distance from the mean, so it is in squared units; take its square root, or use STDEV.S, to get back to the units of your data.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | |
|---|---|---|---|
| 1 | Bag | Line A (g) | Line B (g) |
| 2 | 1 | 501.2 | 503.8 |
| 3 | 2 | 499.8 | 496.2 |
| 4 | 3 | 500.5 | 501.5 |
| 5 | 4 | 498.9 | 497.9 |
| 6 | 5 | 500.1 | 504.6 |
| 7 | 6 | 501 | 495.4 |
| 8 | 7 | 499.5 | 500.9 |
| 9 | 8 | 500.3 | 498.3 |
| 10 | 9 | 499 | 502.7 |
| 11 | 10 | 500.7 | 499.1 |
Download this sheet as an Excel practice file (.xlsx)
VAR.S: variance of a sample
A snack maker checks 10 bags from each filling line against a 500 g target. Line A averages 500.1 g and Line B 500.04 g, so the averages say both lines are on target. Variance says how much the weights scatter around that average.
VAR.S takes each value's distance from the mean, squares it, adds the squares, and divides by n - 1. The formula below writes out exactly that, so you can see the parts; in Excel, =VAR.S(B2:B11) gives the same answer. Like AVERAGE, VAR.S ignores empty cells and text in the range, and it needs at least two numbers or it returns #DIV/0!.
Result: 0.63111111111
About 0.63 g² for Line A. The same calculation on Line B (C2:C11) gives about 9.96 g², more than 15 times as much scatter.
VAR.S or VAR.P: which one to use
VAR.P divides by n instead of n - 1. Use it when the numbers are the whole population: every invoice from last year, when last year is all you want to describe. Use VAR.S when the numbers stand in for something larger. These 10 bags are a sample of everything the line produces, so VAR.S is right here.
Why n - 1? Values in a sample sit closer to their own average than to the true average of the whole population, so the plain average of squared distances comes out a little too small. Dividing by one less corrects that. The gap shrinks as n grows: with 10 values VAR.P is 10% smaller, with 1,000 values it is 0.1% smaller. If you are unsure, use VAR.S.
VAR.P with a single number returns 0. VAR.S with a single number returns #DIV/0!, which is honest: one bag tells you nothing about scatter.
Result: 0.568
About 0.57 g², the population variance of Line A, which is what VAR.P returns. It is exactly 9/10 of the VAR.S result because n is 10.
Variance and standard deviation: square and square root
Standard deviation is the square root of variance, and variance is standard deviation squared. VAR.S pairs with STDEV.S and VAR.P with STDEV.P. Mixing them, such as SQRT(VAR.P(...)) compared against STDEV.S, gives two numbers that look like they should match but do not.
The practical difference is units. Line B's variance of about 10 is in grams squared, which nobody can picture. Its standard deviation is about 3.2 g, which you can: a typical bag is about 3 g off the average. Report standard deviation to people. Use variance when a method calls for it, such as adding up uncertainty: for independent sources of variation, variances add, and standard deviations do not.
Result: 9.9604444444
About 9.96, Line B's sample variance, the same as =VAR.S(C2:C11). Its square root, STDEV.S(C2:C11), is about 3.16 g.
Not the same as budget variance
In finance and accounting, "variance" usually means the difference between actual and budget, such as =C2-B2 or a percentage over or under plan. That has nothing to do with VAR.S. If that is what you need, see the budget vs actual variance guide linked below. VAR.S and VAR.P measure spread, the statistical meaning.
Variance with a condition, and for a whole table
Excel has no VARIF. In Excel 365 or 2021, filter first: =VAR.S(FILTER(C2:C50,B2:B50="Night")) gives the variance for night-shift bags only. In older versions use =VAR.S(IF(B2:B50="Night",C2:C50)) and confirm it with Ctrl+Shift+Enter.
For a full summary at once, turn on the Analysis ToolPak (File > Options > Add-ins > Manage Excel Add-ins > Go, tick Analysis ToolPak). Then Data > Data Analysis > Descriptive Statistics gives mean, standard deviation, sample variance, range and more for each column. Its Sample Variance row is the VAR.S version. The output is static numbers, so rerun it if the data changes.
- Go to Data > Data Analysis and choose Descriptive Statistics.
- Set Input Range to B1:C11, choose Grouped By Columns and tick Labels in first row.
- Pick an output range, tick Summary statistics, and click OK.
Common mistakes
Using VAR.P for a sample
It understates the spread of small samples. If the data stands for future production, all customers or any group bigger than what you measured, use VAR.S.
Reporting variance in the units of the data
A variance of 9.96 is not 9.96 grams; it is grams squared. Quote the standard deviation (about 3.2 g) instead.
Zeros for missing readings
A 0 g entry for a bag that was not weighed adds a giant squared distance. Leave the cell blank so VAR.S ignores it.
Using VARA by accident
VARA and VARPA count text as 0 and TRUE as 1, so a cell that says "n/a" becomes a zero. Use VAR.S and VAR.P for numbers.
FAQ
What is the difference between VAR.S and VAR.P in Excel?
VAR.S treats the data as a sample and divides by n - 1. VAR.P treats it as the whole population and divides by n. VAR.S gives the larger result, and the difference matters most with small data sets.
Is VAR the same as VAR.S?
Yes. VAR and VARP are the older names for VAR.S and VAR.P, kept for compatibility. They give the same results, but the new names make it clear which version you chose.
How do I get standard deviation from variance in Excel?
Take the square root: =SQRT(VAR.S(B2:B11)) gives the same value as =STDEV.S(B2:B11). Going the other way, square the standard deviation.
Can variance be negative?
No. It is an average of squared distances, so the smallest it can be is 0, which means every value is identical. A negative "variance" in a spreadsheet is a budget-style difference, not statistical variance.
Functions used
SUMPRODUCTMultiply then addAVERAGEMean of numbersCOUNTCounts numbersSTDEV.SStandard deviationSQRTSquare root
Related guides
- How to calculate standard deviation in Excel
- How to calculate budget vs actual variance in Excel
- How to calculate an average in Excel
- How to calculate a z-score in Excel
- How to make a gradebook in Excel
- Sum the last N values in a column
- How to calculate CAGR in Excel
Updated