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

How-to basics · Updated November 22, 2026

The two main functions for standard deviation in Excel are STDEV.S (for a sample) and STDEV.P (for an entire population). For most everyday use, type =STDEV.S(range) where range is your data cells, and press Enter — for example, =STDEV.S(A2:A101).

What Standard Deviation Measures

Standard deviation tells you how spread out numbers are from the average (mean). A low value means the data points cluster close to the mean; a high value means they are scattered widely. It is the square root of the variance, and it is expressed in the same units as your original data — so if your data is in dollars, the standard deviation is in dollars too.

Excel offers several related functions, and choosing the wrong one is a common source of confusion. The two you will use most are:

  • STDEV.S — for a sample of a larger population (e.g., 50 customers out of all customers).
  • STDEV.P — for an entire population (e.g., all 1,200 students in a school).

There are also legacy functions STDEV and STDEVP that still work for compatibility, but Microsoft recommends using the newer STDEV.S and STDEV.P because they are more consistent with modern naming.

STDEV.S vs. STDEV.P: Which One to Use

The choice comes down to whether your data is a sample or a population. This is not a stylistic preference — the formulas actually differ mathematically.

  • Sample (STDEV.S): divides by n-1 (where n is the number of data points). This correction makes the sample standard deviation an unbiased estimate of the population standard deviation. Use it when your data is a subset of a larger group.
  • Population (STDEV.P): divides by n. Use it when your data includes every member of the group you are studying.

For example, if you have test scores for all 30 students in a class, that is a population — use STDEV.P. If you randomly selected 30 students from the entire school, that is a sample — use STDEV.S.

If you are unsure, most real-world data is a sample because it is rare to have every single member of a large population. When in doubt, STDEV.S is the safer default.

How to Use STDEV.S and STDEV.P in Excel

Using the functions is straightforward. Suppose your data is in cells B2 through B11 (10 values). To get the sample standard deviation:

  1. Click an empty cell, for example B12.
  2. Type =STDEV.S(B2:B11).
  3. Press Enter. Excel returns the standard deviation.

For population, replace with =STDEV.P(B2:B11).

You can also reference non-contiguous ranges, like =STDEV.S(A2:A10, C2:C10), or list individual numbers, like =STDEV.S(5, 8, 12). In Excel for Microsoft 365, the function accepts up to 254 arguments.

On a Mac, the steps are identical — the function names and syntax are the same. In Excel for the web, the same functions work as well.

What About STDEVA and STDEVPA?

Excel also has STDEVA and STDEVPA functions. These are similar to STDEV.S and STDEV.P, but they treat text and logical values (TRUE/FALSE) as numbers. In the standard functions, text and logicals are ignored.

For example, STDEVA counts TRUE as 1 and FALSE as 0. This is rarely what you want unless you have a specific reason to include such values. In most cases, stick with STDEV.S or STDEV.P.

Common Errors and Problems

Several issues can trip you up when calculating standard deviation in Excel:

  • #DIV/0! error: This occurs if you use STDEV.S with only one data point (because n-1 becomes zero). STDEV.P with one point returns 0.
  • Text or blanks: Both functions ignore text and empty cells. If you have cells with text that look like numbers (e.g., “10” as text), they will be ignored. To fix, convert text to numbers using the VALUE function or the Text to Columns wizard.
  • Logical values: TRUE/FALSE are ignored in STDEV.S and STDEV.P. If you need to include them, use STDEVA or STDEVPA.
  • Wrong function choice: Using STDEV.S when you have a population gives a slightly larger value than STDEV.P. The difference shrinks as the sample size grows, but it is still technically incorrect.

Conditional Standard Deviation with STDEVIF?

Excel does not have a built-in “STDEVIF” function like it has SUMIF or AVERAGEIF. To calculate the standard deviation of a subset of data that meets a condition, you must use an array formula or the newer FILTER function.

For example, suppose you have sales data in A2:A100 and region in B2:B100, and you want the standard deviation of sales for “North”. In Excel 365 or Excel 2021, you can use:

=STDEV.S(FILTER(A2:A100, B2:B100="North"))

This works because FILTER returns the array of sales where region is “North”, and STDEV.S calculates the standard deviation of that array. In older versions without FILTER, you would need an array formula like =STDEV.S(IF(B2:B100="North",A2:A100)) entered with Ctrl+Shift+Enter.

Standard Deviation in Charts and Data Analysis

Standard deviation is often used in charts to show variability. Excel does not have a one-click “add standard deviation bars” button, but you can add custom error bars:

  1. Create a bar or line chart from your data.
  2. Click the chart, then click the Chart Elements button (the plus sign).
  3. Check “Error Bars” and choose “More Options”.
  4. Select “Custom” and specify the range containing your standard deviation values.

Alternatively, the Data Analysis Toolpak add-in includes “Descriptive Statistics”, which outputs standard deviation along with mean, median, and other metrics. To enable it, go to File > Options > Add-ins, select “Analysis ToolPak”, and click Go. Then find it under Data > Data Analysis.

Frequently Asked Questions

What is the difference between STDEV.S and STDEV.P in simple terms?

STDEV.S is for a sample of a larger group, and it divides by n-1 to give an unbiased estimate. STDEV.P is for the entire group, and it divides by n. If you have all the data for the group you care about, use STDEV.P; otherwise use STDEV.S.

How do I calculate standard deviation for only certain rows in Excel?

Use the FILTER function combined with STDEV.S, as shown above. For example, =STDEV.S(FILTER(A2:A100, B2:B100="North")) calculates the standard deviation of values in A where the corresponding B cell is “North”. This works in Excel 365 and Excel 2021.

Why does my standard deviation formula return #DIV/0!?

This error appears when you use STDEV.S with fewer than two numbers. Because the formula divides by n-1, with n=1 it divides by zero. Add more data points, or switch to STDEV.P if you truly have only one value (though that would give 0).

Can I calculate standard deviation for text or logical values?

STDEV.S and STDEV.P ignore text and logical values. If you need to include TRUE/FALSE as 1/0, use STDEVA for a sample or STDEVPA for a population. Text values are always ignored in these functions.

Is there a keyboard shortcut to insert STDEV.S?

There is no dedicated shortcut, but you can press Alt+M (to open the Formulas tab) and then U to open “More Functions”, then S to find statistical functions. Or simply type the function name — Excel’s autocomplete will help. On a Mac, the ribbon shortcuts differ, but typing the function name works the same.

Does Excel for Mac have the same standard deviation functions?

Yes, STDEV.S, STDEV.P, and the others are available in Excel for Mac with the same syntax. The only difference is in keyboard shortcuts and menu navigation, but the formulas work identically.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.