How To Calculate Variance in Excel

Ben Stockton, contributor to the CareerFoundry blog

Calculating variance allows you to determine the spread of numbers in a data set against the mean. This is a great tool for data analysts, who can use Excel to calculate the variance using functions like VAR.S and VAR.P. We’ll explain how to use variance functions in this step-by-step tutorial.

In mathematical terms, variance is the calculation of how far a set of values is from the average value (the mean). If the variance is zero, there isn’t any variety—all numbers are likely to be the same. As this number grows, the variance grows with it.

This has all kinds of uses for analysts, from determining the different ages in a group to working out the spread of returns in different investment portfolios. Excel allows you to calculate variance like this by using functions aimed at entire data sets (population variance) or a small subset of a larger group of data (sample variance).

This is an important distinction, as the way Excel calculates variance will differ depending on the size of your data set. If you’re working with a smaller sample, you’ll need to use VAR, VAR.S, or VARA functions to calculate variance. For population variance, you’ll need to use VARP, VAR.P, or VARPA instead.

While there are similarities between these functions, there are some important things to consider before you use them. In this article, we’ll explain:

  1. What are variance functions in Excel and what are they used for?
  2. How do variance functions work in Microsoft Excel?
  3. Things to consider before using variance functions in Excel
  4. How to calculate variance in Excel: A step by-step guide

How do variance functions work in Excel? To help you, let’s run through the basics.

1. What are variance functions in Excel and what are they used for?

Variance works by determining the spread of values against the mean. If you have a set of exam results for a group of students, you might end up with wildly different values in two separate exams, but with the same average. By determining the variance, you can determine how well the group performed as a whole.

An Excel spreadsheet containing data for student ID, student name, and exam result

You can calculate this spread (the variance) using Excel’s variance functions. As we’ve mentioned, there are two main forms of variance that you can calculate in Excel: population variance and sample variance. In this context, population is the entire set of data, rather than a sample (or smaller subset) of it.

To calculate these values, you can use one of six variance functions in Excel. For sample variance, you can use the VAR, VAR.S or VARA functions. VAR is the original function, while VAR.S is the newer replacement, offering some speed enhancements over the original.

VAR and VAR.S only support numerical values, but if you want to use text strings or logical tests for a sample set, you’ll need to use VARA instead.

For population variance, you’ll need to use the VARP, VAR.P or VARPA functions. As with the sample variance functions, VARP is the original, while VAR.P is the newer (and recommended) replacement, with both functions working only with numerical values. To work with text strings or logicals, use VARPA instead.

If you’re thinking that this sounds a lot like standard deviation, that’s because it (almost) is. Standard deviation calculates, on average, how far your values are from the mean. Variation is simply the standard deviation value squared, which gives you an idea of how far all of your numbers are spread from the average.

2. How do variance functions work in Excel?

As we’ve already mentioned, there are six variance functions that you can use in Excel, split into two categories to deal with either population or sample variation.

These are:

  • VAR, VAR.S or VARA for sample variance, and
  • VARP, VAR.P or VARPA for population variance.

Of these six, two functions (VAR and VARP) are considered outdated, having been replaced with VAR.S and VAR.P. These are interchangeable for the time being, but could be removed from Excel in the future.

An Excel spreadsheet containing data for student ID, student name, and exam result. The VARA formula has been typed into the formula bar

Four of these functions (VAR, VARP, VAR.S and VAR.P)focus on numerical data. That means that, if you’re a budding data analyst trying to work out the variance from a set of numbers using either a sample of a data set or the entire data set, you’d want to use these functions.

Should your data be mixed, however, you’ll need to use VARA or VARPA instead. These functions support text, numbers, and logical values (TRUE, FALSE, 1 or 0).

An Excel spreadsheet containing data for student ID, student name, and exam result. The VARA formula has been typed into the formula bar

By support, we mean that text strings and logical results are converted to the numerical equivalent, where a text string is counted as a 0 (or FALSE). Logical values are counted as their numerical equivalent (0 for FALSE or 1 for TRUE). This can have an impact on your overall results, so choose your functions carefully.

If you want to create a formula using any of these variance functions, you’ll need to use a set structure. The structure remains the same for each six functions:

  • =VAR(value1,value2, …)
  • =VAR.S(value1,value2, …)
  • =VARP(value1,value2, …)
  • =VAR.P(value1,value2, …)
  • =VARA(value1,value2, …)
  • =VARPA(value1,value2, **…)**

An Excel spreadsheet with the VARA function typed into the formula bar with a range of cells selected

The only required argument in a variance formula using these functions is the reference to the data you use (value1). This can be referenced as a range of cells or as values directly (where value1 is your first value, value2 is your second value, etc).

Only one value (value1) is required for a variance function to work. For cell ranges, this is considered as a single value (value1) for the purpose of creating your formula.

3. Things to consider before using variance functions in Excel

There are plenty of considerations to make before you decide to calculate variance in Excel using these functions. In particular, you’ll need to consider:

  • While VAR and VAR.S are technically interchangeable, VAR.S is the replacement Excel function for sample data sets and should be used in the first instance. Likewise, VAR.P should be used over VARP for population data sets as the newer function.
  • VAR, VAR.S, VARP and VARP only support numerical values. Other values (text strings, logical values, etc.) are ignored and won’t count towards your result.
  • If you want to count text or logical values as you calculate variance, you’ll need to use VARA (for samples) or VARPA (for population sets).
  • You can use references to cell ranges (eg. =VAR.S(A1:D10)) in your variance formulas, or reference each value separately (eg. =VAR.S(1,2,3,4)).
  • If you reference each value separately, you can use up to 254 different values. This is an Excel limitation and can’t be increased. If you require more, fill out your spreadsheet first, then use a reference to the cell range containing those cells instead.
  • Only a single argument (value1) is required, which can contain a single value or a reference to a range of cells. However, to calculate variance from a single value is redundant, so you’ll need to use more arguments if you’re typing these into your formula directly.
  • If you’re adding a text string as a value in a variance formula, you’ll need to reference it in another cell for the formula to work, as directly adding a text string as a value argument will cause a #VALUE error to appear.

4. How to calculate variance in Excel: A step by-step guide

If you have a small sample from a larger data set, you can use the VAR, VAR.S or VARA functions to calculate the variance. If you’re trying to calculate variance in Excel using the population data set (that is, the entire set of data, rather than the smaller sample), you can do this using VARP, VAR.P or VARPA instead.

For the purpose of this guide, references to VAR and VAR.S are interchangeable. We’ve used VAR.S, which is the newer and recommended function, but the older VAR can be used (for the time being) in older workbooks. If you can, however, use VAR.S.

Likewise, references to VARP and VAR.P are also interchangeable, but you should use VAR.P in the first instance. VARA and VARPA remain available for all Excel users, regardless of the version used.

Step 1: Select an empty cell

To insert a variance function into a new formula, start by opening the Excel workbook containing your data and selecting an empty cell. Alternatively, you can open a new workbook, making sure that the sheet containing your data remains open and minimized.

With the cell selected, press the formula bar at the bottom of the ribbon bar until you see the blinking cursor.

An Excel spreadsheet containing data for student ID, student name, and exam result. A red arrow is pointing to the formula bar, and an empty cell has been selected

When the blinking cursor is visible, you’re ready to begin inserting your new formula.

Step 2: Insert your data set directly or using cell references

As we explained earlier, all variance functions in Excel use the same structure to create new formulas. To insert a new variance function using a sample data set (a smaller sample of a larger population set), start by typing =VAR.S( or =VARA( into the formula bar at the top.

If you’re working with a population data set (the entire data set), type =VAR.P( or =VARPA( instead.

An Excel spreadsheet containing data for student ID, student name, and exam result. The VAR.P formula has been typed into the formula bar

With your formula opened, you’ll need to insert your data next. Most users will likely prefer to reference data elsewhere in your current workbook (or in a minimized workbook) using a cell range.

For instance, =VAR.S(C2:C10) or =VAR.P(C2:C20) completes the formula, using the numerical data in a cell range between cells C2 and C10 (for the sample set) or C2 and C20 (for the population set). Make sure to replace these references with your own.

If you’re working with data that contains numbers, text, and/or logical values, =VARA(C2:C10) or =VARPA(C2:C20) will work best. Rather than ignoring text or logical values (as VAR, VAR.S, VARP or VAR.P would), the values in a VARA or VARPA formula will count towards your overall result.

You could also reference each cell individually. For example =VARA(C2:C10) and =VARA(C2,C3,C4,C5,C6,C7,C8,C9,C10) will return the same result.

If you’re adding numerical values directly to your formula, you’ll need to add the values one by one. Each value needs to be separated using commas. For instance, =VAR.S(1,2,3,4,5,6) or =VAR.P(1,2,3,4,5,6,7,8,9,10) will give you the variance between the numbers 1 and 6 (or 1 and 10 for a population set) directly.

An Excel spreadsheet containing data for student ID, student name, and exam result. The VAR.S formula has been typed into the formula bar

You can also do the same with VARA or VARPA. For example, =VARA(1,2,TRUE,3) would work, with the TRUE value counting as its numerical equivalent (1). Likewise, =VARPA(1,2,TRUE,3,4,10,8) would count these values in the same way, with TRUE counting as 1.

VARA and VARPA support text, but to use these, you’ll need to use a cell reference or cell range. For instance, =VARA(1,2,TRUE,D5,3,4,10,8) or =VARA(D2:D9) would work, where D5 contains text that counts as a FALSE value (0). If you try to add a text string directly, however, Excel will return a #VALUE error.

An Excel spreadsheet containing data for student ID, student name, and exam result. The VARA formula has been typed into the formula bar

If you’ve added a reference to a cell range, make sure to close your formula with a closing parenthesis afterwards, then press enter to view the results (or click on another empty cell). For values added directly, place a closing parenthesis after the final value is inserted into your formula.

Final thoughts

By calculating the variance, you can learn a lot about the data you’re working with. This makes the life of a typical data analyst even easier, allowing you to prove theories and hypotheses using a single Excel formula. Variance functions are among the many Excel formulas that data analysts use on a regular basis to find results.

Excel makes mathematical functions like variance and standard deviation easier to handle, especially for beginners. There are also scripts on the internet that make it a little easier, such as this variance calculator—but it’s way more rewarding to learn how to calculate variance on your own!

If you’re new to the field and you want to learn more, try this free, five-day introductory data analytics course. And, if you’re keen to get to grips with more Excel formulas, check out the following:

What is CareerFoundry?

CareerFoundry is an online school for people looking to switch to a rewarding career in tech. Select a program, get paired with an expert mentor and tutor, and become a job-ready designer, developer, or analyst from scratch, or your money back.

Learn more about our programs
blog-footer-image