Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Standard deviation in Excel and Google Sheets

Two shops both average 40 orders a day. One sells 38 to 42 every day; the other swings from 25 to 55. The average cannot tell them apart. The standard deviation can.

ABC
1DayNorthSouth
213825
324155
434040
543930
654252
764045
874128
983950
1094035
11104040
12Average4040
13Std dev1.1510.48

Sample data: orders a day at two shops over 10 days. B12 holds =AVERAGE(B2:B11) and B13 holds =STDEV.S(B2:B11), both filled right to column C. Results shown to 2 decimal places.

The formula

Click B13 and type:

=STDEV.S(B2:B11)

North shows 1.15. Fill it right and South shows 10.48. Both shops average 40, but on a typical day North lands about 1 order away from its average and South about 10.

The answer is in the same units as your data, here orders a day. A small number means the values sit close together; a big one means they are spread out. It is never negative, and it is 0 only when every value is the same.

What the number tells you

Take one standard deviation off the average and add one on, and you get the usual range. For South:

=AVERAGE(C2:C11)-STDEV.S(C2:C11)

gives 29.52, and the same with a plus gives 50.48. Six of South's 10 days fall between them. North's range is 38.85 to 41.15, and 8 of its 10 days fall inside. To count them for you:

=COUNTIFS(C2:C11,">="&AVERAGE(C2:C11)-STDEV.S(C2:C11),C2:C11,"<="&AVERAGE(C2:C11)+STDEV.S(C2:C11))

To compare spread between things of different sizes, divide by the average:

=STDEV.S(C2:C11)/AVERAGE(C2:C11)

South gives 0.26 and North 0.03. Format the cell as a percent and it reads 26% against 3%: South swings about a quarter of its average from day to day. Statisticians call this the coefficient of variation.

STDEV.S or STDEV.P?

  • STDEV.S (S for sample): your numbers are part of something bigger and you want to know about the bigger thing. Ten days to judge how a shop usually does, 30 customers out of thousands, this term's tests to judge a student.
  • STDEV.P (P for population): your numbers are the whole group and you only want to describe them. Every person on a six person team, every month of last year when last year is all you are asking about.

Microsoft's STDEV.S page says it uses the "n-1" method, and to use STDEV.P "If your data represents the entire population". For South, =STDEV.P(C2:C11) gives 9.94 against 10.48. With 10 values the two differ by about 5%; with 100 values it is about half a percent. Not sure which? Most real data is a sample, so STDEV.S is the usual pick.

Old names: STDEV is the same as STDEV.S and STDEVP the same as STDEV.P. Both still work in Excel and Google Sheets, so an older file that uses them is fine.

The working, by hand

Here is what the function does, on five numbers: 2, 4, 8, 11 and 15.

  1. The average: 2 + 4 + 8 + 11 + 15 = 40, and 40 / 5 = 8.
  2. How far each one is from 8: -6, -4, 0, 3 and 7.
  3. Square each: 36, 16, 0, 9 and 49. They add up to 110 (=DEVSQ(A1:A5) gives the same).
  4. Divide. For the whole group, divide by 5: 110 / 5 = 22. For a sample, divide by one less, 4: 110 / 4 = 27.5. That result is the variance.
  5. Take the square root: about 4.690 for the whole group and 5.244 for a sample.

With the numbers in A1:A5, =VAR.P(A1:A5) gives 22, =STDEV.P(A1:A5) 4.690, =VAR.S(A1:A5) 27.5 and =STDEV.S(A1:A5) 5.244. Dividing by 5 or by 4 is the whole difference between P and S. The standard deviation is the square root of the variance, so =SQRT(VAR.S(C2:C11)) gives 10.48, the same as STDEV.S.

A number stored as text, a blank or a 0

STDEV.S quietly leaves out anything in the range that is not a number. Microsoft's page says "Empty cells, logical values, text, or error values in the array or reference are ignored", and Google's STDEV page says cells that contain text are ignored.

  • A number stored as text. If South's 55 on day 2 was pasted in as text, =STDEV.S(C2:C11) gives 9.6 instead of 10.48 and the average drops to 38.33, because day 2 is left out with no warning. To check a column, =COUNTA(C2:C11)-COUNT(C2:C11) gives 1: one cell holds something that is not a number. Our page on numbers stored as text has the fixes.
  • A blank is skipped, which is right for a day you have no number for. Leave day 11 empty and =STDEV.S(C2:C12) still gives 10.48.
  • A 0 counts as a real value. Type 0 for a day South was closed and the standard deviation jumps to 15.63 and the average falls to 36.36. Leave a closed day blank unless zero orders is what you want to measure.

STDEV.S needs at least two numbers: =STDEV.S(B2) on one cell gives #DIV/0!, while =STDEV.P(B2) gives 0.

One group from a longer list

Most data comes as one long list with a column saying which group each row is in. With the shop in A2:A21 and the orders in B2:B21:

=STDEV.S(FILTER(B2:B21,A2:A21="North"))

gives 1.15 for North, and the same with "South" gives 10.48. =STDEV.S(B2:B21) on all 20 rows gives 7.25, which mixes the two shops and describes neither. FILTER works in Excel for Microsoft 365, Excel 2021 and Google Sheets.

No formula at all (Excel): a PivotTable does it. Insert > PivotTable, drag Shop to Rows and Orders to Values, then right-click a number in the PivotTable and choose Summarize Values By > More Options. StdDev is the sample version (STDEV.S) and StdDevp the whole-group version (STDEV.P). You get one standard deviation per shop plus one for everything. Refresh the PivotTable after the data changes.

Spot an odd value with a z-score

A z-score says how many standard deviations a value is from the average:

=STANDARDIZE(C2,AVERAGE($C$2:$C$11),STDEV.S($C$2:$C$11))

South's day 1 (25 orders) gives -1.43 and day 2 (55) gives 1.43. To flag anything far out, fill this down next to the data:

=IF(ABS(STANDARDIZE(C2,AVERAGE($C$2:$C$11),STDEV.S($C$2:$C$11)))>2,"Check","")

The catch with short lists. Say North's day 3 was typed as 400 instead of 40. Its z-score is only 2.85, because the 400 also blows up the standard deviation (113.85). With n values, no z-score can go past (n-1) divided by the square root of n, which is 2.85 for 10 values. So a "more than 3" rule never flags anything in a list of 10 or fewer, even a typo ten times too big. Use 2 for short lists, or use quartile fences, which a single wild value cannot stretch:

=QUARTILE.INC(B2:B11,3)+1.5*(QUARTILE.INC(B2:B11,3)-QUARTILE.INC(B2:B11,1))

That gives 43.625, and the lower fence (the first quartile minus the same 1.5 times the gap) gives 36.625. Only the 400 falls outside them.

Free practice sheet

Try it on three everyday jobs: which of two coffee trucks is steadier, STDEV.S or STDEV.P for a team and a batch, and a typo in a short list of delivery times. Each tab has yellow cells to fill in and a Check column that says Correct or Try again as you type, plus an Answers tab. One Excel file that opens in Google Sheets too. Free, no sign up. Sample data.

Download the practice sheet (.xlsx, 11 KB)

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

Teaching this to a class or team?

Get one tip like this a month

A free email from VARS Digital with one Excel or Google Sheets fix, tested in both apps. No spam, unsubscribe any time.

By signing up you agree that VARS Digital, 10151 240 Street, Maple Ridge, BC V2W 0G9, Canada (inquiries@varsdigital.app) may email you its newsletter: Excel and Google Sheets tips, updates and news about our templates and lessons. We send a confirmation email first, and nothing else goes out until you click it. Every email has an unsubscribe link, and you can leave any time. Details in our store policies.

More how-tos