## How to use the VAR.S function

The VAR.S function tries to estimate the variance based on a sample of the population. The function ignores logical and text values.

The VAR.P function also calculates the variance, however, it assumes the data set is the entire population and not a sample. This makes the output differ slightly from these two functions.

**What is the variance measure in statistics?**

The variance shows how much a set of numbers are spread out from their average value.

Variance tells you how far from the average values are spread out. Both charts above have numbers and an average plotted, they share the same average however, the numbers are not the same.

Chart A above shows that the values are more spread out than the values in chart B. Chart A has a variance of approx 550.02, the variance for chart B is approx 27.11. Variance is often used in statistics.

### Table of contents

## 1. VAR.S Function Syntax

VAR.S(*number1*,[*number2*],...)

## 2. VAR.S Function Arguments

number1 |
Required.Â A cell reference to the sample of the population. |

number2 |
Optional. Up to 254 additional arguments. |

## 3. VAR.S Function example

Formula in cellÂ B13:

The formula calculatesÂ the variance of the numbers in cell range B3:B7.

Both Set1 and Set2 above have the same average 30, however, values in Set2 are much more spread out.

Set1 variance: 212.5 and Set2 variance: 10750.

### 3.1 How is the output from the VAR.S function calculated?

The equation for VAR.S is:

xÂ Ì…Â is the sample mean AVERAGE(number1,number2,â€¦)

n is the sample size.

Using the example above (Set1), the average of 10, 30, 25, 50 andÂ 35 is 30.

(10-30)^2+(30-30)^2+(25-30)^2+(50-30)^2+(35-30)^2 = 850

850 / 4 = 212.5.

### 3.2 What is the difference between the standard deviation and variance?

Standard deviation is the square root of the variance. Both standard deviation and variance describes how spread out data is, but standard deviation is more commonly used because it is easier to relate to the data points.

For example, if the average weight of a group of people is 140 pounds and the standard deviation is 40 pounds, you can conclude that most people are within 40 pounds of the average weight. Variance, on the other hand, would be 1600, which is harder to interpret. However, variance is easier to calculate.

VAR.S function formula:

STDEV.S function formula:

The VAR.S formula tries to estimate the standard deviation based on a sample of a population whereas VAR.P calculates the standard deviation of the whole population.

The image above shows the VAR.P formula to calculate the standard deviation of a population.

## 4. Sort rows by variance based on a sample of a population

This example demonstrates a formula in cell B8 that sorts rows from cell range B3:N6 by the variance of a sample from large to small. Cell ranges P3:P6 and P7:P11 contains the variances.

### Explaining formula

#### Step 1 - Calculate the variance of a sample

VAR.S(a)

#### Step 2 - Build the LAMBDA function

The LAMBDA function build custom functions without VBA, macros or javascript.

Function syntax: LAMBDA([parameter1, parameter2, â€¦,] calculation)

LAMBDA(a,VAR.S(a))

#### Step 3 - Calculate the variance of a sample by row

The BYROW function puts values from an array into a LAMBDA function row-wise.

Function syntax: BYROW(array, lambda(array, calculation))

BYROW(C3:N6,LAMBDA(a,VAR.S(a)))

returns

{51514.0606060606; 88506.5151515151; 95454.2424242424; 45039.4242424243}

#### Step 4 - Sort rows based on the variance of a sample

The SORTBY function sorts a cell range or array based on values in a corresponding range or array.

Function syntax: SORTBY(array, by_array1, [sort_order1], [by_array2, sort_order2],â€¦)

SORTBY(B3:N6,BYROW(C3:N6,LAMBDA(a,VAR.S(a))),-1)

becomes

SORTBY(B3:N6,{51514.0606060606;88506.5151515151;95454.2424242424;45039.4242424243},-1)

and returns

### Functions in 'Statistical' category

The VAR.S function function is one of many functions in the 'Statistical' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form