Google Sheets – How to Calculate Variance with Criteria

formulasgoogle sheets

I would like to know how to calculate variance (VAR, VARA, VARP) with criteria as in AVERAGEIF and AVERAGEIFS. The VARIF function does not seem to exist. This question also applies to others functions such as median, etc.

Best Answer

The FILTER function can be used to first select the parts of the range that meet your criteria. That result can then be passed to VAR (e.g. =VAR(FILTER(source_range, condition))).

FILTER can also be used to filter one column based on a condition on another column. For example, if you have columns:

x | 1
y | 2
x | 3

You can find the VAR for the rows that have x in the first column like this:

=VAR(FILTER(B:B, A:A = "x"))