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.
| A | B | C | |
|---|---|---|---|
| 1 | Day | North | South |
| 2 | 1 | 38 | 25 |
| 3 | 2 | 41 | 55 |
| 4 | 3 | 40 | 40 |
| 5 | 4 | 39 | 30 |
| 6 | 5 | 42 | 52 |
| 7 | 6 | 40 | 45 |
| 8 | 7 | 41 | 28 |
| 9 | 8 | 39 | 50 |
| 10 | 9 | 40 | 35 |
| 11 | 10 | 40 | 40 |
| 12 | Average | 40 | 40 |
| 13 | Std dev | 1.15 | 10.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.
- The average: 2 + 4 + 8 + 11 + 15 = 40, and 40 / 5 = 8.
- How far each one is from 8: -6, -4, 0, 3 and 7.
- Square each: 36, 16, 0, 9 and 49. They add up to 110 (=DEVSQ(A1:A5) gives the same).
- 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.
- 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.
- Sales Tracker and Dashboard 2027Log every sale and see revenue, top products and top customers on a dashboard.
- Teacher GradebookOne class of up to 40 students: type the scores and see the overall percent, letter grade and missing work.
- Inventory SpreadsheetStock tracker with a reorder list and a stock in and out log.
Teaching this to a class or team?
More how-tos
- Find a price by its code with XLOOKUPType a product code, get its price back from your price list. One formula, no helper columns.
- Total each category with SUMIFSAdd up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.
- Check two conditions at once with IF and ANDFree shipping only when the order is 50 or more and ships in Canada: one IF, one AND, done.
- Add leading zeros to numbersType 00021 and Excel or Google Sheets shows 21, because to them it is just the number 21. Here is how to get the zeros back, and keep them.
- Fix #DIV/0! in an averageAn average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.
- Count rows that meet two conditions with COUNTIFSHow many of Ana's deals were 500 or more? COUNTIFS answers it in one cell, and takes as many rules as you need.
- Calculate percentage changeSales went from 400 to 500. That is a 25% increase, and one short formula works it out for every row.
- Calculate years of service from a start dateAna started on 15 March 2019. How many full years has she worked? DATEDIF counts them, and the same formula works out an age from a date of birth.
- Combine first and last name into one cellFirst names in one column, last names in the next, and you need "Ana Lopez" in one cell. The & sign joins them.
- Find duplicates in a list with COUNTIFA mailing list where some people signed up twice. One formula shows how many times each email appears, so the repeats stand out.
- Split a full name into first and last nameYour list has "Ana Lopez" in one cell and you need Ana and Lopez in two. Two short formulas find the space and split there.
- Total amounts by month with SUMIFSA list of dated expenses and you want one total per month. SUMIFS adds every amount between the first and the last day of the month.
- Count working days between two datesAna is off from 1 Oct to 14 Oct. How many working days is that? NETWORKDAYS counts Monday to Friday and leaves out the weekends.
- Hide #N/A in VLOOKUP with IFERRORYour order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.
- Count cells that contain textA stock list where some items have a note and most do not. One COUNTIF with an asterisk counts the notes and skips the empty cells.
- Make a running total (cumulative sum)Monthly sales in one column, the total so far in the next. One formula, filled down.
- Round to 2 decimal places, up or downA 15% discount turns 12.99 into 11.0415. ROUND makes it 11.04 and keeps your totals right to the cent. ROUNDUP and ROUNDDOWN handle the times when nearest is the wrong answer.
- How long to $1,000,000? FV and NPERPut $500 a month away at an example 7% a year. FV says what it grows to, NPER says when it passes $1,000,000. Two formulas, no calculator site.
- Why your formula gives the wrong number: the order of operationsA2 holds 10 and A3 holds 4. What does =A2-A3*2 give? It is 2, not 12. The same rule explains most formulas that look right and give the wrong number.
- Why your SUM says 0, and how to fix itThe amounts are right there in the column, and the total says 0. They look like numbers, but the sheet has them stored as text, and SUM skips text.
- Fill handle not working? Copy a formula down fastYou wrote one formula and need it in every row. Here are the quick ways to copy it down, and what to check when the fill handle will not show up or the copies come out wrong.
- Calculate hours worked from start and end timesA shift from 9:00 to 17:30 is 8.5 hours, but subtract the times and the cell shows 8:30. One small change turns it into a number you can add up and multiply by a pay rate.
- IF a cell is blank, or not blankYou want a formula to do one thing when a cell is empty and something else when it is filled. Two double quotes do the job, and they also catch the blanks ISBLANK misses.
- Formulas not updating? Recalculate and refreshYou change a number and the total does not move. It is nearly always one of a handful of things, and each one takes seconds to fix once you know which.
- Stack several columns into one column with TOCOLNames in three columns, one for each day, and you need them in one list. One formula does it, and the list keeps up when the columns change.
- Long numbers turn into E+ or end in 0 in ExcelYou type a 12 digit order number and Excel shows 5.93774E+11. You type a 16 digit account number and the last digit turns into 0. The first one is only how the cell looks. The second is a real loss, and it has to be stopped before you type.
- Count how many times each value appears in a columnA staff list with a department on every row, and you need to know how many people are in each department. Two short formulas build the count table, and it keeps up when the list changes.
- Free pricing calculatorsPrice a job from your real costs and margin. No sign up.
- Free downloadsPractice sheets and printable pages, no email and no sign up.







