DVAR
Returns the sample variance of a database field for records matching criteria.
DVAR filters records first, then computes variance using the sample denominator (n - 1).
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=DVAR(database, field, criteria)
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
database | any | Required | — |
field | any | Required | — |
criteria | any | Required | — |
Remarks
- An equality criterion for a date or number (
"10/26/1999","36459",36459) also matches text cells holding that date;<>and ordering criteria do not read date text. - Criteria rows are OR alternatives; criteria columns within each row are AND constraints.
Error cases
fieldcan be resolved by case-insensitive header text or 1-based index; unresolved fields return#VALUE!.- At least two numeric values must match criteria, otherwise the function returns
#DIV/0!.
Examples
Estimate the sample variance of the Score column for the two East records.
Formula =DVAR(A1:B4,"Score",D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result 2
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use field number 2 to get the same sample variance for East.
Formula =DVAR(A1:B4,2,D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result 2
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
The West sample has only one record, so IFERROR handles the undefined sample variance.
Formula =IFERROR(DVAR(A1:B4,"Score",E1:E2),"Insufficient data")
| A | B | E | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "West" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result Insufficient data
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
The missing field header prevents calculating the sample variance for East.
Formula =DVAR(A1:B4,"Missing",D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result #VALUE!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Sample variance of units for East or West
Formula =DVAR(A1:E7, "Units", G1:G3)
| A | B | C | D | E | G | |
|---|---|---|---|---|---|---|
| 1 | "Region" | "Salesperson" | "Product" | "Units" | "Revenue" | "Region" |
| 2 | "West" | "Diaz" | "Widget" | 24 | 126000 | "East" |
| 3 | "East" | "Patel" | "Gadget" | 31 | 142500 | "West" |
| 4 | "North" | "Kim" | "Widget" | 18 | 87000 | |
| 5 | "West" | "Ramos" | "Service" | 12 | 46000 | |
| 6 | "South" | "Lee" | "Gadget" | 27 | 119000 | |
| 7 | "East" | "Noor" | "Widget" | 22 | 101000 |
Expected result 61.5833333333333
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Sample variance of widget revenue
Formula =DVAR(A1:E7, 5, G1:G2)
| A | B | C | D | E | G | |
|---|---|---|---|---|---|---|
| 1 | "Region" | "Salesperson" | "Product" | "Units" | "Revenue" | "Product" |
| 2 | "West" | "Diaz" | "Widget" | 24 | 126000 | "Widget" |
| 3 | "East" | "Patel" | "Gadget" | 31 | 142500 | |
| 4 | "North" | "Kim" | "Widget" | 18 | 87000 | |
| 5 | "West" | "Ramos" | "Service" | 12 | 46000 | |
| 6 | "South" | "Lee" | "Gadget" | 27 | 119000 | |
| 7 | "East" | "Noor" | "Widget" | 22 | 101000 |
Expected result 390333333.333333
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
Does DVAR use sample or population variance math?
DVAR uses sample variance with an n-1 denominator and returns #DIV/0! when fewer than two numeric rows match.