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
LanguageName in Excel
ArabicDVAR
BulgarianDVAR
CzechDVAR.VÝBĚR
DanishDVAR
GermanDVAR
GreekDVAR
English (Australia)DVAR
English (United Kingdom)DVAR
English (United States)DVAR
SpanishBDVAR
EstonianDVAR
FinnishTVARIANSSI
FrenchBDVAR
HebrewDVAR
CroatianDVAR
HungarianAB.VAR
IndonesianDVAR
ItalianDVAR
JapaneseDVAR
KoreanDVAR
LithuanianDVAR
LatvianDVAR
NorwegianDVAR
DutchDBVAR
PolishBD.WARIANCJA
Portuguese (Brazil)DVAR
Portuguese (Portugal)BDVAR
RomanianDVAR
RussianБДДИСП
SlovakDVAR
SlovenianDVAR
Serbian (Latin)DVAR
SwedishDVARIANS
ThaiDVAR
TurkishVSEÇVAR işlevi
UkrainianDVAR
VietnameseDVAR
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

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

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 separates DVAR from 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; DVAR is not a lift kernel.

Errors

ErrorCondition
#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
propagatedAn error value in a header cell, a criteria cell, or a scanned field cell surfaces as that error

How to implement

Notes for implementers

  1. 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.
  2. The minimum-count check precedes the arithmetic, so #DIV/0! is a domain decision, not a division that happened to have a zero denominator.
  3. Skip, do not coerce. Admit only cells whose value kind is Number; n is the count of collected numbers.
  4. 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 GitHub
11 dvar "DVAR" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Var) }

Kernels shared with other functions

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 × n whenever both are defined.
  • DSTDEV is SQRT(DVAR) — the same selection, the same estimator, one extra operation.
  • Nearest modern equivalents: VAR.S combined with a filtered array, or VAR.S over a FILTER result in a dynamic-array workbook. Excel's own compatibility pairing is VAR (legacy) / VAR.S (modern); the database family was not renamed in that pass and DVAR keeps its name and its sample semantics.
  • Confused with: VAR.P/DVARP (the divisor), and VARA, which counts logicals and text.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents