Menu

Standard Deviation in Excel: STDEV.S vs STDEV.P

=STDEV.S(B2:B9) gives the standard deviation of a sample and =STDEV.P(B2:B9) of a whole population. Use STDEV.S unless your data is every value there is. VAR.S and VAR.P give the variance.

Every sheet on this page is live: change a number or a formula and it recalculates.

=STDEV.S(B2:B9) returns the standard deviation of the values in B2:B9 treated as a sample, and =STDEV.P(B2:B9) treats them as the whole population. The standard deviation says how far values typically sit from their average: a small one means the values are close together.

Standard deviation of test scores
E2
ABCDE
1StudentScoreMeasureResult
2Ana72STDEV.S12.82853961
3Ben84STDEV.P12
4Cleo84Average90
5Dan84
6Eve90
7Finn90
8Gia102
9Hal114
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The scores average 90. STDEV.P gives exactly 12 and STDEV.S gives about 12.83. Change Hal's score to 90 and both drop sharply: one value far from the rest moves the standard deviation a lot.

STDEV.S vs STDEV.P: which one to use

The two differ in one step. STDEV.P divides the sum of squared differences by the number of values, n. STDEV.S divides by n minus 1, which makes the result slightly larger. The reason: a sample's spread is measured around the sample's own average, which sits closer to its values than the true average does, so dividing by n would understate the spread of the whole group.

  • STDEV.P (population): the range holds every value you want to describe. The scores of all 8 students in this class, when the question is about this class.
  • STDEV.S (sample): the range is a part of something bigger. 8 students picked from a school of 600, used to estimate the spread of the whole school.

When in doubt, use STDEV.S. Most data in a spreadsheet is a sample, and statistics tools (t tests, confidence intervals) expect the sample version. With hundreds of values the two results are almost the same; with 8 values the gap is about 7%.

The older functions STDEV and STDEVP give the same results as STDEV.S and STDEV.P and still work in every version of Excel. STDEVA and STDEVPA also count text as 0 and TRUE as 1, which is rarely what you want.

How Excel calculates it, step by step

This sheet does by hand what STDEV.S does in one call: subtract the average from each value, square the differences, add them up, divide by n minus 1, and take the square root.

Standard deviation by hand
F5
ABCDEF
1ValueDifferenceSquaredResult
24-24Sum of squares34
3824n6
4600Variance (sample)6.8
55-11Std dev (sample)2.607680962
63-39STDEV.S2.607680962
710416
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The sum of squares is 34, the sample variance is 6.8, and its square root (about 2.61) matches STDEV.S in F6. Change F4 to =F2/F3 and you get the population variance; its square root is what STDEV.P returns.

Variance: VAR.S and VAR.P

The variance is the standard deviation before the square root: =VAR.S(A2:A7) gives 6.8 for the data above, and =VAR.P(A2:A7) divides by n instead of n minus 1. Variance is in squared units (points squared, dollars squared), so for reporting, the standard deviation is easier to read. VAR and VARP are the old names.

Mean plus or minus one standard deviation

A common way to report spread is "mean ± SD", for example 90 ± 12.8. The two ends of that range are simple formulas, and a conditional formatting rule can mark the values outside it.

Values more than one SD from the mean
E3
ABCDE
1StudentScoreMeasureValue
2Ana72Mean90.0
3Ben84SD12.8
4Cleo84Low77.2
5Dan84High102.8
6Eve90
7Finn90
8Gia102
9Hal114
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The rule highlights Ana and Hal, the two scores outside about 77.2 to 102.8. In normally distributed data about two thirds of the values fall within one standard deviation of the mean, and about 95% within two. To format the text in a cell as "90.0 ± 12.8", use =TEXT(E2,"0.0")&" ± "&TEXT(E3,"0.0").

Standard deviation with a condition

There is no STDEVIF function. Put an IF inside STDEV.S: IF returns the score where the region matches and FALSE elsewhere, and STDEV.S skips the FALSE values.

Standard deviation for one region
E2
ABCDE
1RegionSalesRegionSTDEV.S
2North120North25.61737691
3South95South3.872983346
4North150
5South101
6North90
7South98
8North135
9South104
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

North's sales vary much more than South's. In Excel 365 and 2021 this formula works as typed. In Excel 2019 and earlier, finish it with Ctrl+Shift+Enter (Cmd+Shift+Enter on a Mac) or it returns a wrong result or #VALUE!. With Excel 365 you can also write =STDEV.S(FILTER(B2:B9,A2:A9=D2)).

Try it: spread of delivery times

Delivery times in days
E2
ABCDE
1OrderDaysStd dev
2A13
3A25
4A34
5A49
6A53
7A64
8A76
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: The orders in B2:B8 are a sample of all orders. In E2, calculate their standard deviation.

Hint: a sample means the function ending in .S.

Common mistake: the total row in the range

A range like B2:B10 that also takes in a total or an average at the bottom of the column treats that summary as one more data point, and the standard deviation comes out far too large. Select only the data rows, or keep summaries in a different column, as the sheets on this page do. Empty cells and text in the range are ignored, but a 0 is a value and counts: a missing score typed as 0 widens the spread just as a real 0 would. To check how many values were used, put =COUNT(B2:B9) next to the result.

Frequently Asked Questions

What is the formula for standard deviation in Excel?

=STDEV.S(B2:B9) for a sample and =STDEV.P(B2:B9) for a full population. Both ignore text and empty cells in the range.

Should I use STDEV.S or STDEV.P?

Use STDEV.P only when the range holds every member of the group you describe, such as all 8 people on a team. When the data is a sample used to describe something larger (some customers, some test runs), use STDEV.S. With many values the two are close; with few values STDEV.S is noticeably larger.

What is the difference between STDEV and STDEV.S?

None in the result. STDEV and STDEVP are the pre-2010 names, kept for compatibility; STDEV.S and STDEV.P are the current ones. Google Sheets accepts both sets of names.

How do I calculate variance in Excel?

Use =VAR.S(B2:B9) for a sample and =VAR.P(B2:B9) for a population. The variance is the standard deviation squared, so =STDEV.S(B2:B9)^2 gives the same number as VAR.S.

How do I calculate the standard error in Excel?

Excel has no function for the standard error of the mean. Divide the sample standard deviation by the square root of the count: =STDEV.S(B2:B9)/SQRT(COUNT(B2:B9)).

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED