Database functions
DVAR
Matches all 3 recorded answers
Recorded: 3 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | DVAR |
| Bulgarian | DVAR |
| Czech | DVAR.VÝBĚR |
| Danish | DVAR |
| German | DVAR |
| Greek | DVAR |
| English (Australia) | DVAR |
| English (United Kingdom) | DVAR |
| English (United States) | DVAR |
| Spanish | BDVAR |
| Estonian | DVAR |
| Finnish | TVARIANSSI |
| French | BDVAR |
| Hebrew | DVAR |
| Croatian | DVAR |
| Hungarian | AB.VAR |
| Indonesian | DVAR |
| Italian | DVAR |
| Japanese | DVAR |
| Korean | DVAR |
| Lithuanian | DVAR |
| Latvian | DVAR |
| Norwegian | DVAR |
| Dutch | DBVAR |
| Polish | BD.WARIANCJA |
| Portuguese (Brazil) | DVAR |
| Portuguese (Portugal) | BDVAR |
| Romanian | DVAR |
| Russian | БДДИСП |
| Slovak | DVAR |
| Slovenian | DVAR |
| Serbian (Latin) | DVAR |
| Swedish | DVARIANS |
| Thai | DVAR |
| Turkish | VSEÇVAR işlevi |
| Ukrainian | DVAR |
| Vietnamese | DVAR |
| Chinese (Simplified) | DVAR |
| Chinese (Hong Kong) | DVAR |
| Chinese (Traditional) | DVAR |
Names from Microsoft's support site.
What it does
DVAR(database, field, criteria)
DVAR(database, field, criteria) selects the records of database that satisfy criteria,
reads the column named by field, and returns the sample variance of the numeric values
found there.
With R the set of selected record rows, c the resolved field column,
V = [ v₁ … vₙ ] = the Numbers in cell (r, c) for r in R, in record order
and n = |V|, the result is
x̄ = (Σ vᵢ) / n
s² = ( Σ (vᵢ − x̄)² ) / (n − 1)
Sample variance divides by n − 1, so at least two values are required; with fewer the divisor is zero or negative and the function is in error territory (see below).
Non-numeric cells in the field column — text, logicals, blanks — are skipped, so n counts numbers, not records. A matching record with a blank field cell reduces n by one; it does not contribute a zero.
The selection stage — header matching, AND across a criteria row, OR down the rows, blank criteria cells, and criteria-expression parsing — is identical for all twelve database functions and is explained once in the criteria-range mechanism.
Why the formula, not just the definition
The two textbook formulas for variance are algebraically identical and numerically are not:
(A) two-pass: s² = Σ(vᵢ − x̄)² / (n − 1)
(B) sum-of-squares: s² = ( Σvᵢ² − (Σvᵢ)²/n ) / (n − 1)
Arguments
Three arguments, all required at the call site; the reference implementation declares an arity of exactly 3.
database— the header-plus-records range or array.field— the column selector, as header text or as a 1-based column index within the database range. Required.criteria— the header-plus-conditions range or array.
Try it
Quirks
Result and edge cases
Returns a Number, always non-negative when computed by form (A).
- Fewer than two numeric values selected — no match, one match, or matches whose field cells
are mostly blank:
#DIV/0!. This is the boundary that separatesDVARfrom DVARP, which needs only one value. - All selected values equal:
0, exactly, under form (A) — every deviation is exactly zero. Under form (B) it need not be. - Text that looks numeric in the field column is skipped, per the range-scan side of the asymmetry in coercion and lifting.
- Logicals in the field column are skipped.
- Arrays: inline array literals resolve to grids and are accepted;
DVARis not a lift kernel.
Errors
| Error | Condition |
|---|---|
#DIV/0! | Fewer than two numeric values were collected from the field column of the matching records |
#VALUE! | database or criteria is not a grid or is empty; a database header cell is blank; a criteria header names no database field; field matches no header, or is a non-integer or out-of-range column index |
| propagated | An error value in a header cell, a criteria cell, or a scanned field cell surfaces as that error |
How to implement
Notes for implementers
- Both passes are sequential left folds in record order, per the family's declared reduction policy. That fixes the mean's last bits, which in turn fixes every deviation.
- The minimum-count check precedes the arithmetic, so
#DIV/0!is a domain decision, not a division that happened to have a zero denominator. - Skip, do not coerce. Admit only cells whose value kind is Number; n is the count of collected numbers.
- Numeric criteria comparison is not exact double comparison — see the note in the shared mechanism. For the statistical members this has a second-order effect worth noting: a tolerant match can change n, and n appears in the divisor.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
DVAR · 1 lines · calc-func/src/catalogue/database.rs on GitHub11 dvar "DVAR" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Var) }
Kernels shared with other functions
readercatalogue/aggregateread_referencecatalogue/aggregatenumberscatalogue/comparisonin_bandcatalogue/comparisonRounded::upcatalogue/comparisonRoundings::ofcatalogue/comparisonRoundings::disjointcatalogue/comparisontextscatalogue/comparisoncomparecatalogue/comparison/collationweighedcatalogue/comparison/collationmeasured_iteration_extensioncatalogue/comparison/collationtablecatalogue/comparison/sort_keydecode64catalogue/comparison/sort_keyReader::bytecatalogue/comparison/sort_keyReader::varintcatalogue/comparison/sort_keyReader::donecatalogue/comparison/sort_keyin_rangescatalogue/comparison/sort_keybuildcatalogue/comparison/sort_keyhan_basecatalogue/comparison/sort_keyderivecatalogue/comparison/sort_keyshared_jamo_tailscatalogue/comparison/sort_keyordinary_jamo_prefixcatalogue/comparison/sort_keyindependent_jamo_suffixcatalogue/comparison/sort_keyjamo_leading_primarycatalogue/comparison/sort_keyleading_ordercatalogue/comparison/sort_keyBefore::separate_specialcatalogue/comparison/sort_keyGathered::kanacatalogue/comparison/sort_keyGathered::unitcatalogue/comparison/sort_keypartscatalogue/comparison/sort_keydiacritic_ordercatalogue/comparison/sort_keydiacriticscatalogue/comparison/sort_keyrangecatalogue/conditionalrowcatalogue/conditionaloffsetcatalogue/conditionalread_rangecatalogue/conditionalverdictscatalogue/conditionalusedcatalogue/conditionalMatch::ofcatalogue/conditionalMatch::negatedcatalogue/conditionalOp::holdscatalogue/conditionalOp::is_equalitycatalogue/conditionalspellscatalogue/conditionalcriterioncatalogue/conditionaldatabase_criterioncatalogue/conditionalrankcatalogue/conditionalcriterion_textcatalogue/conditionaldecidedcatalogue/conditionalCriterion::verdictcatalogue/conditionalequalitycatalogue/conditionalis_surrogatecatalogue/conditionalwildcardcatalogue/conditionallabelcatalogue/databasesame_labelcatalogue/databasefieldcatalogue/databasematchingcatalogue/databasecriterion_verdictcatalogue/databasedatabasecatalogue/databasepublishedcatalogue/databaselow32decimalNatural::from_u64decimalNatural::pow10decimalNatural::normalizedecimalNatural::is_zerodecimalNatural::mul_add_smalldecimalNatural::times_pow10decimalNatural::times_pow5decimalNatural::times_pow2decimalExactDecimal::binarydecimalexcel_sqrt_stagedported/excel_numerictextported/text_kernelstext_from_strported/text_kernelsfold_unitported/text_kernelspush_singleton_or_originalported/text_kernelspush_lowerported/text_kernelslowerported/text_kernelsvariance_from_valuesported/variance_commonstdev_from_valuesported/variance_common
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
- DVARP is the population form: divisor n instead of n − 1, and one value
is enough.
DVAR × (n − 1) = DVARP × nwhenever both are defined. - DSTDEV is
SQRT(DVAR)— the same selection, the same estimator, one extra operation. - Nearest modern equivalents:
VAR.Scombined with a filtered array, orVAR.Sover aFILTERresult in a dynamic-array workbook. Excel's own compatibility pairing isVAR(legacy) /VAR.S(modern); the database family was not renamed in that pass andDVARkeeps its name and its sample semantics. - Confused with:
VAR.P/DVARP(the divisor), andVARA, which counts logicals and text.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents