Skip to content

Lesson 34 of 92 · Free Excel Course

Excel

How to Calculate Variance in Excel (VAR.S vs VAR.P) and Other Statistics

Calculate variance and standard deviation in Excel, sample vs population, with a worked example. Plus MEDIAN, MODE, percentiles, CORREL and the Analysis ToolPak.

Variance tells you how spread out a list of numbers is. Two classes can both average 80 on a test, but in one class everybody scored between 75 and 85 and in the other the scores run from 50 to 100. The averages match; the variance doesn't. In Excel you calculate it with VAR.S or VAR.P, and the hardest part is knowing which one to pick. This lesson works through a variance by hand, step by step, so you can see exactly what Excel does. Then it covers standard deviation, the median, the mode, percentiles and quartiles, correlation, and the Analysis ToolPak's one-click summary. It picks up where Average, MIN, MAX and COUNT left off.

Sample or population? The one decision that matters

Every spread function in Excel comes in two versions, and the letter after the dot tells you which:

  • .S means sample. Your numbers are some of a bigger group, and you want to say something about the whole group. One class out of a school, 200 customers out of 10,000, this month's orders as a guide to future months. Almost all real data is a sample.
  • .P means population. Your numbers are every member of the group, and you only care about that group. The final scores of the 10 students in your class, when you only want to describe those 10.

Why does it change the answer? A sample tends to underestimate how spread out the full group really is, because it usually misses the most extreme values. So the sample formula divides by one less than the count (n - 1) instead of the count (n), which nudges the answer up a little to make up for it. With 10 values the difference is noticeable; with 1,000 it's tiny.

If you're unsure, use the .S version. It's the safer choice and it's what most statistics courses expect.

Calculate variance by hand: a worked example

Here are the practice workbook's 10 test scores, in B2:B11. We'll find the variance the long way first, using two helper columns, and then let Excel confirm it.

D2=B2-AVERAGE($B$2:$B$11)
ABCDE
1StudentScoreHours studiedDeviationSquared
2Ava723-864
3Ben856525
4Cara90710100
5Dev641-16256
6Ella785-24
7Finn855525
8Gia93813169
9Hugo702-10100
10Iris886864
11Jack754-525
12Total800470832
Column D is each score minus the average of 80. Column E squares it. The squared deviations add up to 832.
  1. Find the mean. The scores add up to 800 and there are 10 of them, so the average is 80. In Excel: =AVERAGE(B2:B11).
  2. Find each deviation. Subtract the mean from every score. Ava scored 72, so her deviation is 72 - 80 = -8. In D2 type =B2-AVERAGE($B$2:$B$11) and copy it down. The dollar signs keep the range fixed (see Absolute and relative references).
  3. Square each deviation. Squaring removes the minus signs, so scores below and above the average both count as spread: -8 squared is 64. In E2 type =D2^2 and copy it down.
  4. Add up the squares. =SUM(E2:E11) gives 832. (The deviations themselves always add up to 0, which is why we square them first.)
  5. Divide. For a sample, divide by n - 1: 832 / 9 = 92.44. For a population, divide by n: 832 / 10 = 83.2.
  6. Take the square root for the standard deviation. The square root of 92.44 is 9.61; the square root of 83.2 is 9.12.

Now type =VAR.S(B2:B11) in an empty cell. You get 92.444, exactly what you worked out in step 5. =VAR.P(B2:B11) gives 83.2. That's all the variance functions do: steps 1 to 5 in one go.

VAR.S, VAR.P, STDEV.S and STDEV.P

All four have the same shape: =VAR.S(number1, [number2], ...). Usually you give them a single range, like B2:B11, but you can list up to 254 numbers or ranges.

C4=STDEV.S(B2:B11)
ABC
1StatisticFormulaResult
2Sample variance=VAR.S(B2:B11)92.44
3Population variance=VAR.P(B2:B11)83.20
4Sample standard deviation=STDEV.S(B2:B11)9.61
5Population standard deviation=STDEV.P(B2:B11)9.12
The four spread functions on the same 10 scores. Each standard deviation is the square root of the variance above it.

Which should you report? Standard deviation, usually. Variance is in "points squared", which doesn't mean much to anyone. A standard deviation of 9.61 says scores typically land about 9.6 points either side of the average of 80.

A few rules from Microsoft's documentation worth knowing:

  • In a range, only numbers count. Blank cells, text and TRUE/FALSE are skipped. A real 0 is included, so don't type 0 for "no score yet"; leave it blank.
  • You need at least two numbers for VAR.S and STDEV.S, or you get #DIV/0! (n - 1 would be zero).
  • VAR, STDEV, VARP and STDEVP are the old names. VAR equals VAR.S and VARP equals VAR.P. They still work, but use the new ones.
  • VARA and STDEVA also count TRUE as 1 and text in a range as 0. You'll rarely want that.

All four new functions work in Excel for Microsoft 365 on Windows and Mac, Excel for the web, and Excel 2016 to 2024.

MEDIAN and MODE.SNGL: the middle and the most common

The average can be pulled around by one very high or low value. The median is the middle value when the list is sorted, so one odd score barely moves it.

  • =MEDIAN(B2:B11) returns 81.5. Sorted, the scores are 64, 70, 72, 75, 78, 85, 85, 88, 90, 93. With an even count there are two middle values (78 and 85), and Excel averages them.
  • =MODE.SNGL(B2:B11) returns 85, the only score that appears twice. If no value repeats, MODE.SNGL returns #N/A. That isn't a broken formula; it means there's no mode. The old =MODE() gives the same result.

House prices and salaries are usually reported as medians for exactly this reason: one mansion doesn't make the typical house look more expensive.

Percentiles and quartiles

A percentile tells you the value below which a given share of the data falls. =PERCENTILE.INC(B2:B11,0.9) returns 90.3: 90% of the scores are at or below 90.3. The k argument is a decimal from 0 to 1, so 0.9 means the 90th percentile. When the spot falls between two scores, Excel estimates a value between them (here, between 90 and 93).

Quartiles are just the 25th, 50th and 75th percentiles, with their own function, =QUARTILE.INC(array, quart):

quartReturnsOur scores
0Minimum64
1First quartile (25th percentile)72.75
2Median81.5
3Third quartile (75th percentile)87.25
4Maximum93

Q3 minus Q1 (87.25 - 72.75 = 14.5) is the interquartile range: how spread out the middle half of the class is.

What about the .EXC versions? PERCENTILE.EXC and QUARTILE.EXC use a slightly different method that leaves out the very ends of the data. QUARTILE.EXC only accepts 1, 2 or 3, and on our scores gives Q1 = 71.5 and Q3 = 88.5. Stick with .INC unless a course or textbook tells you to use the exclusive method; .INC matches the old QUARTILE and PERCENTILE functions.

CORREL: do two columns move together?

The practice data also records how many hours each student studied. =CORREL(B2:B11,C2:C11) returns 0.98.

  • Close to +1: when one goes up, the other goes up. Here, more study hours went with higher scores.
  • Close to -1: when one goes up, the other goes down.
  • Close to 0: no straight-line relationship.

Both ranges must be the same size, or CORREL returns #N/A. A correlation shows that two things move together; it doesn't prove one causes the other. To see the pattern, add a scatter chart (see Charts and graphs).

The Analysis ToolPak: Descriptive Statistics and Histogram

The Analysis ToolPak is a free add-in that comes with desktop Excel but is switched off by default.

Turn it on (Windows):

  1. Click File, then Options, then Add-ins.
  2. At the bottom, set Manage to Excel Add-ins and click Go.
  3. Tick Analysis ToolPak and click OK. If Excel says it isn't installed, click Yes to install it.

On a Mac: click Tools, then Excel Add-ins, tick Analysis ToolPak, click OK, then quit and restart Excel. In Excel for the web: Microsoft says the ToolPak can't currently be added there. Open the file in the desktop app, or use the formulas from this lesson.

Once it's on, Data Analysis appears at the right-hand end of the Data tab.

Descriptive Statistics gives you a whole summary table at once. Click Data Analysis, choose Descriptive Statistics, and click OK. Set the Input Range to B1:B11, tick Labels in first row, choose where the output goes, tick Summary statistics, and click OK:

GH
1Score
2Mean80
3Standard Error3.04
4Median81.5
5Mode85
6Standard Deviation9.61
7Sample Variance92.44
8Kurtosis-1.17
9Skewness-0.28
10Range29
11Minimum64
12Maximum93
13Sum800
14Count10
Descriptive Statistics for the 10 scores (rounded here; Excel shows more decimals). Note it reports the sample variance and standard deviation.

Notice the labels: Sample Variance and a standard deviation that matches STDEV.S. The ToolPak always treats your data as a sample. Standard Error is the standard deviation divided by the square root of the count (9.61 / 3.16 = 3.04). Kurtosis and skewness describe the shape of the data; values near 0 mean roughly bell-shaped.

Histogram counts how many values fall into ranges ("bins") you choose. Type bin edges in a column (for example 60, 70, 80, 90, 100), then choose Data Analysis, Histogram, set the Input Range and Bin Range, and tick Chart Output if you want a chart too. Excel 2016 and later can also make a histogram chart straight from the Insert tab without the ToolPak.

One catch: the ToolPak writes plain numbers, not formulas. Change a score and the table doesn't update; you have to run it again. That's why the practice workbook rebuilds the same table with formulas such as =STDEV.S(B2:B11)/SQRT(COUNT(B2:B11)).

Which one do I use?

You want to know...Use
How spread out a sample is (most data)STDEV.S (or VAR.S if asked for variance)
How spread out a complete group isSTDEV.P or VAR.P
The typical value when there are outliersMEDIAN
The most common valueMODE.SNGL
The value that a given % of data is belowPERCENTILE.INC
The quarter points of the dataQUARTILE.INC
Whether two columns move togetherCORREL
A full summary in one clickAnalysis ToolPak, Descriptive Statistics

Try it yourself

Download the practice workbook. The Practice sheet has the 10 scores and yellow cells for your answers.

  1. In D2 type =B2-AVERAGE($B$2:$B$11) and in E2 =D2^2, then copy both down to row 11. The squares should total 832.
  2. In H5, divide that total by 9 to get the sample variance by hand (92.44).
  3. Check it with =VAR.S(B2:B11), then try =VAR.P, =STDEV.S and =STDEV.P.
  4. Add MEDIAN (81.5), MODE.SNGL (85), the 90th percentile (90.3) and the two quartiles (72.75 and 87.25).
  5. Find =CORREL(B2:B11,C2:C11) (about 0.98).
  6. On desktop Excel, run Descriptive Statistics on B1:B11 and compare it with the formula version on the Answers sheet.

The Answers sheet has every formula, a check cell that shows "Match" when your hand calculation equals VAR.S, and the Descriptive Statistics table rebuilt with formulas.

Common mistakes

  • Using .P for a sample. If your data is a sample, VAR.P and STDEV.P understate the spread. Default to .S.
  • Mixing the pair. Reporting VAR.S next to STDEV.P gives numbers that don't match. Square STDEV.S and you should get VAR.S.
  • Zeros for missing values. A typed 0 is a real score and drags the spread up. Leave missing values blank.
  • Numbers stored as text. Pasted numbers aligned to the left are skipped by these functions. Convert them back to numbers first.
  • Forgetting to rerun the ToolPak. Its output never updates. Use formulas if the data will change.
  • Reading CORREL as cause. A strong correlation only says the columns move together.

What's next

You can now measure spread properly, pick the right version every time, and summarise a list in one click. The previous lesson, Loan and finance formulas, covered PMT, interest and savings. Next, Excel with AI and Copilot shows how to ask Excel's AI for formulas like these, and how to check that what it writes is right. You can also go back to the full Excel course. For single functions, see the RANK, LARGE, SMALL, CORREL and FREQUENCY reference pages.

Frequently asked questions

Should I use VAR.S or VAR.P?

Use VAR.S when your numbers are a sample taken from a bigger group (a survey, some of the year's orders, one class out of a whole school). Use VAR.P only when you have every value in the group you care about and won't draw conclusions beyond it. If you're not sure, VAR.S is the usual choice. The same rule applies to STDEV.S and STDEV.P.

Why is VAR.S bigger than VAR.P?

Both add up the same squared deviations, but VAR.S divides by one less than the count (n - 1) and VAR.P divides by the count (n). Dividing by a smaller number gives a bigger answer. In this lesson's 10 scores the total is 832, so VAR.S is 832/9 = 92.44 and VAR.P is 832/10 = 83.2. The gap shrinks as you add more values.

What's the difference between variance and standard deviation?

Standard deviation is the square root of the variance. Variance is in squared units (points squared), which is hard to picture, so most people report the standard deviation, which is back in the original units. A standard deviation of 9.6 points means scores typically sit about 9.6 points from the average.

What's the difference between VAR and VAR.S, or STDEV and STDEV.S?

They give the same answer. VAR and STDEV are the older names (sample versions) that Microsoft keeps for compatibility, and VARP and STDEVP are the old population versions. Microsoft recommends the newer VAR.S, VAR.P, STDEV.S and STDEV.P, which work in Microsoft 365 (Windows, Mac and the web) and Excel 2016 to 2024.

Can I use the Analysis ToolPak in Excel for the web?

No. Microsoft says the Data Analysis ToolPak can't currently be added in Excel for the web. Use the desktop app on Windows or Mac, or use the formulas in this lesson, which work everywhere and give the same numbers as the Descriptive Statistics tool.

How do I calculate percent variance (budget vs actual)?

That's a different kind of variance: the difference between two numbers. Use =(Actual-Budget)/Budget and format the cell as a percentage, so a budget of 500 and actual spending of 550 gives 10%. See Percentages for more. The VAR functions in this lesson measure spread in a list of numbers instead.