Computes the variance among all values in a column=20 using the sample statistical method. Input column can be of In= teger or Decimal. If no numeric values are detected in the input colum= n, the function returns

`0`

.
The **variance** of a set of values attempts to measur=
e the spread in values around the mean. A variance of zero means that all v=
alues are the same, and a small variance means that the values are closely =
bunched together. A high value for variance indicates that the numbers are =
spread out widely. Variance is always a positive value.

If a row contains a missing or null value, it is not factored into the c= alculation.

**NOTE: **This function applies to a sample of the entire p=
opulation. More information is below.

In the following computation, the sample method computes variances with =
*N - 1* as the divisor.

*Var(X) =3D [Sum ((X - mean(X)) ^{2})] / (Count(X) - 1)*

The square root of variance is standard deviation, which is used to meas= ure variance under the assumption of a bell curve distribution. See STDEV Function.

For a version of this function co= mputed over a rolling window of rows, see ROLLINGVAR Function.

**Wrangle vs. SQL:** This function is part of Wrangle , a proprietary data transformation language.=
Wrangle is not SQL. For more information, se=
e Wrangle Language.

varsamp(myRating)

**Ou=
tput:** Returns the variance of the group of values from the&nb=
sp;`myRating`

column using the =
sample method of calculation.

varsamp(col_ref) [group:group= _col_ref] [limit:limit_count]

=20
=20
=20
=20
=20

Argument | Required? | Data Type | Description |
---|---|---|---|

function_col_ref | Y | string | Name of column to which to apply the funct= ion |

For more information on the `group`

and ```
limit=
```

parameters, see Pivot Transform.

For more information on syntax standards, see Language Documentation Syntax Note= s.

Name of the column whose values you wish to use in the calculation. Colu= mn must be a numeric (Integer or Decimal) type.

- Literal values are not supported as inputs.
- Multiple columns and wildcards are not supported.

**Usage Notes:**

=20
=20
=20
=20

Required? | Data Type | Example Value |
---|---|---|

Yes | String (column reference) | `myValues` |

**Tip:** For additional examples, see Common Tasks.

This example shows some of the statistical functions that use the= sample method of computation. These include:

`STDEVSAMP`

- computes standard deviation using the sam= ple method. See STDEVSAMP= Function.`VARSAMP`

- computes variance using the sample met= hod. See VARSAMP Function.`STDEVSAMPIF`

- computes standard deviation based on a = condition and using the sample method. See STDEVSAMPIF Function.`VARSAMPIF`

- computes standard deviation based on= a condition and using the sample method. See VARSAMPIF Function.

**Source:**

Students took tests on three consecutive Saturdays:

=20

Student | Date | Score |
---|---|---|

Andrew | 11/9/19 | 81 |

Bella | 11/9/19 | 84 |

Christina | 11/9/19 | 79 |

David | 11/9/19 | 64 |

Ellen | 11/9/19 | 61 |

Fred | 11/9/19 | 63 |

Andrew | 11/16/19 | 73 |

Bella | 11/16/19 | 88 |

Christina | 11/16/19 | 78 |

David | 11/16/19 | 67 |

Ellen | 11/16/19 | 87 |

Fred | 11/16/19 | 90 |

Andrew | 11/23/19 | 76 |

Bella | 11/23/19 | 93 |

Christina | 11/23/19 | 81 |

David | 11/23/19 | 97 |

Ellen | 11/23/19 | 97 |

Fred | 11/23/19 | 91 |

**Transformation:**

You can use the following transformations to calculate standard deviatio= n and variance across all dates using the sample method. Each computation h= as been rounded to three digits.

=20

=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

=20
Transformation Name | <= code>New formula |
---|---|

Parameter: Formula type | `Single row formula` |

Parameter: Formula | `round(stdevsamp(Score), 3)` |

Parameter: New column name | `'stdevSamp'` |

=20

=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

=20
Transformation Name | <= code>New formula |
---|---|

Parameter: Formula type | `Single row formula` |

Parameter: Formula | `round(varsamp(Score), 3)` |

Parameter: New column name | `'varSamp'` |

You can use the following to limit the previous statistical computations= to the last two Saturdays of testing:

=20

=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

=20
Transformation Name | <= code>New formula |
---|---|

Parameter: Formula type | `Single row formula` |

Parameter: Formula | ```
round(stdevsampif(Score, Date !=3D '11\/9\=
/2019'), 3)
``` |

Parameter: New column name | `'stdevSampIf'` |

=20

=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20
=20

=20
Transformation Name | <= code>New formula |
---|---|

Parameter: Formula type | `Single row formula` |

Parameter: Formula | ```
round(varsampif(Score, Date !=3D '11\/9\/2=
019'), 3)
``` |

Parameter: New column name | `'varSampIf'` |

**Results:**

Student | Date | Score | varSampIf | stdevSampIf | varSamp | stdevSamp |
---|---|---|---|---|---|---|

Andrew | 11/9/19 | 81 | 94.515 | 9.722 | 131.673 | 11.475 |

Bella | 11/9/19 | 84 | 94.515 | 9.722 | 131.673 | 11.475 |

Christina | 11/9/19 | 79 | 94.515 | 9.722 | 131.673 | 11.475 |

David | 11/9/19 | 64 | 94.515 | 9.722 | 131.673 | 11.475 |

Ellen | 11/9/19 | 61 | 94.515 | 9.722 | 131.673 | 11.475 |

Fred | 11/9/19 | 63 | 94.515 | 9.722 | 131.673 | 11.475 |

Andrew | 11/16/19 | 73 | 94.515 | 9.722 | 131.673 | 11.475 |

Bella | 11/16/19 | 88 | 94.515 | 9.722 | 131.673 | 11.475 |

Christina | 11/16/19 | 78 | 94.515 | 9.722 | 131.673 | 11.475 |

David | 11/16/19 | 67 | 94.515 | 9.722 | 131.673 | 11.475 |

Ellen | 11/16/19 | 87 | 94.515 | 9.722 | 131.673 | 11.475 |

Fred | 11/16/19 | 90 | 94.515 | 9.722 | 131.673 | 11.475 |

Andrew | 11/23/19 | 76 | 94.515 | 9.722 | 131.673 | 11.475 |

Bella | 11/23/19 | 93 | 94.515 | 9.722 | 131.673 | 11.475 |

Christina | 11/23/19 | 81 | 94.515 | 9.722 | 131.673 | 11.475 |

David | 11/23/19 | 97 | 94.515 | 9.722 | 131.673 | 11.475 |

Ellen | 11/23/19 | 97 | 94.515 | 9.722 | 131.673 | 11.475 |

Fred | 11/23/19 | 91 | 94.515 | 9.722 | 131.673 | 11.475 |

=20