# How to calculate standard deviation in Excel

Use `=STDEV.S(B2:B9)` for a sample, which is the usual case, or `=STDEV.P(B2:B9)` when the data is the whole population.

**Excel:** `=STDEV.S(B2:B9)` (Excel 2010 and later)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Order | Delivery days |  | Standard deviation |
| D-1 | 3 |  |  |
| D-2 | 5 |  |  |
| D-3 | 4 |  |  |
| D-4 | 7 |  |  |
| D-5 | 4 |  |  |
| D-6 | 2 |  |  |
| D-7 | 6 |  |  |
| D-8 | 5 |  |  |

Formula in E1: `=STDEV.S(B2:B9)`

Result: 1.60

## How it works

Standard deviation measures how far values typically sit from the average (4.5 days here). STDEV.S treats the eight orders as a sample of all orders and divides by n − 1, which gives about 1.60 days. STDEV.P divides by n and is for when you have every value there is.

## Other ways

- `=STDEV(B2:B9)`: The older name for STDEV.S; still works.
- `=STDEV.P(B2:B9)`: For a complete population. (Divides by n instead of n − 1: 1.50.)

## Common mistakes

- Text and blanks in the range are ignored, but zeros count. A 0 used for "missing" inflates the spread.
- With a single value, STDEV.S returns #DIV/0! because n − 1 is 0.

## Questions

**Should I use STDEV.S or STDEV.P?**

Use STDEV.S unless the data is every member of the group you care about, like every employee rather than a survey of some.

**How do I calculate standard deviation with a condition?**

Filter first: `=STDEV.S(FILTER(B2:B9,B2:B9>2))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/standard-deviation
