Google Sheets VAR.S Function: How to Calculate Sample Variance
In this article
The VAR.S function in Google Sheets calculates the variance of a sample of data. Variance measures how far a set of numbers is spread out from their average value; a high variance indicates that the data points are far from the mean and from each other, while a low variance indicates they are clustered closely around the average. Use VAR.S when you are analyzing a small subset (a sample) of a larger population to estimate the overall volatility or dispersion of that population.
What You'll Need
- A Google account with access to Google Sheets.
- A dataset consisting of numerical values (integers or decimals).
- A clear understanding of whether your data represents a total population or just a sample of a population.
Step-by-Step
- Organize Your Data: Input your numerical values into a single column or row. For example, if you are tracking the daily energy usage of five smart plugs over a week to estimate the usage of all plugs in your home, list these values in cells A1 through A35. Ensure there are no text strings or symbols (like currency signs typed manually) inside the cells, as this can sometimes lead to calculation errors.
- Select the Output Cell: Click on the empty cell where you want the variance result to appear. This is typically a cell below or to the right of your data range.
- Enter the Function Formula: Type
=VAR.S(into the cell. The equals sign tells Google Sheets you are starting a formula, and the open parenthesis prepares the function to receive its arguments. - Define the Data Range: While the parenthesis is open, you can either type the range manually (e.g.,
A1:A35) or use your mouse to click and drag across the cells containing your data. The formula should now look like=VAR.S(A1:A35). - Close and Execute: Type the closing parenthesis
)and press the Enter key. Google Sheets will instantly calculate the sample variance and display the result in the cell. - Format the Result: If the resulting number has too many decimal places, use the "Decrease decimal places" button in the toolbar (usually represented by a .00 with a left-pointing arrow) to make the number more readable.
Common Mistakes
One of the most frequent errors is using VAR.S when you actually have the entire population of data. In statistics, there is a critical difference between a sample and a population. If you have every single data point that exists for the group you are studying, you should use VAR.P. Using VAR.S on a full population will result in a slightly lower variance value because VAR.S uses "Bessel's correction," dividing by n-1 instead of n to account for the bias inherent in sampling.
Another common mistake is including non-numeric data within the selected range. While Google Sheets is generally good at ignoring blank cells and text, including cells that contain errors (like #REF! or #VALUE!) will cause the VAR.S function to return an error. Always clean your data to ensure that only numbers or truly empty cells are included in the range.
Users also frequently forget that variance is expressed in squared units. For instance, if your data is measured in kilowatts, the result of VAR.S will be in squared kilowatts. This often leads people to believe the result is "wrong" because the number is unexpectedly large. To get a value back into the original unit of measurement, you must take the square root of the variance, which is the Standard Deviation (calculated using the STDEV.S function).
Tips
To make your spreadsheet more dynamic, use named ranges. Instead of typing A1:A35, you can highlight that range, go to Data > Named ranges, and name it "EnergyUsage". Your formula then becomes =VAR.S(EnergyUsage). This makes the formula much easier to read and maintain, especially in complex sheets with hundreds of calculations.
If you have data spread across different parts of the sheet, you can include multiple non-contiguous ranges in a single VAR.S function. Simply separate the ranges with commas: =VAR.S(A1:A10, C1:C10, E1:E10). This allows you to calculate the variance of a sample that is split across various columns without having to move the data into one long list.
Combine VAR.S with the IF function if you need to calculate variance based on specific criteria. While VAR.S doesn't have a built-in "IF" version (like SUMIF), you can use =VAR.S(FILTER(A1:A35, B1:B35="Active")). This tells Google Sheets to first filter the data in column A to only include rows where column B says "Active," and then calculate the variance of that specific sample.
Troubleshooting
If your VAR.S function returns a #DIV/0! error, it is almost always because you have fewer than two numeric values in your selected range. Because the sample variance formula divides by n-1, if you only have one number, the formula attempts to divide by zero, which is mathematically impossible. To fix this, ensure your range includes at least two distinct numbers.
If the result seems wildly inaccurate, check for "hidden" characters in your data. Sometimes numbers imported from other software are formatted as text. You can tell if a number is being treated as text if it is aligned to the left of the cell by default. To fix this, highlight the range, go to Format > Number, and select "Number".
If you see a #VALUE! error, check for cells that contain formulas resulting in errors. If a cell within your range is showing #N/A or #VALUE!, the VAR.S function cannot process the range. You can wrap your source data in an IFERROR function to replace those errors with blanks, which VAR.S will then ignore.
Frequently Asked Questions
What is the difference between VAR.S and VAR.P?
VAR.S is for a sample (a portion of the group), while VAR.P is for the entire population. VAR.S uses a formula that corrects for bias in small samples by dividing by the number of data points minus one.
Does VAR.S ignore empty cells?
Yes, Google Sheets automatically ignores empty cells and cells containing text when calculating variance. Only cells containing numerical values are factored into the calculation.
Can I use VAR.S for data in different sheets?
Yes. You can reference another sheet by including the sheet name followed by an exclamation point. For example: =VAR.S('Sheet2'!A1:A100).
Why is my variance number so much larger than my average?
Variance squares the differences from the mean. If your data points are spread far apart, the squaring process exponentially increases the result. This is normal behavior for variance; use STDEV.S for a more intuitive measure of spread.
Is VAR.S the same as the old VAR function?
Yes, in Google Sheets, the VAR function is an alias for VAR.S. Both perform the sample variance calculation, but VAR.S is the current standard for clarity.