Database functions

DSUM

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
ArabicDSUM
BulgarianDSUM
CzechDSUMA
DanishDSUM
GermanDSUM
GreekDSUM
English (Australia)DSUM
English (United Kingdom)DSUM
English (United States)DSUM
SpanishBDSUMA
EstonianDSUM
FinnishTSUMMA
FrenchBDSOMME
HebrewDSUM
CroatianDSUM
HungarianAB.SZUM
IndonesianDSUM
ItalianDSUM
JapaneseDSUM
KoreanDSUM
LithuanianDSUM
LatvianDSUM
NorwegianDSUM
DutchDBSOM
PolishBD.SUMA
Portuguese (Brazil)DSUM
Portuguese (Portugal)BDSOMA
RomanianDSUM
RussianБДСУММ
SlovakDSUM
SlovenianDSUM
Serbian (Latin)DSUM
SwedishDSUMMA
ThaiDSUM
TurkishVSEÇTOPLA işlevi
UkrainianDSUM
VietnameseDSUM
Chinese (Simplified)DSUM
Chinese (Hong Kong)DSUM
Chinese (Traditional)DSUM

Names from Microsoft's support site.

What it does

DSUM(database, field, criteria)

DSUM(database, field, criteria) selects the records of database that satisfy criteria, reads the column named by field, and returns the sum of the numeric values found there.

With R the set of selected record rows, c the resolved field column, and

V = [ v : v = value of cell (r, c) for r in R, in record order, where v is a Number ]

the result is Σ V, summed as a left fold in record order. An empty V sums to 0 — DSUM has no empty-selection error, which is the main behavioural difference between it and DAVERAGE.

Non-numeric cells in the field column contribute nothing: text (including text that reads as a number), logicals, and blanks are skipped rather than coerced to zero. The distinction matters because "skipped" and "added as zero" give the same total but different behaviour in the sibling aggregates that count or divide.

The selection stage — how criteria picks records, how header matching works, what AND across a row and OR down the rows mean, what a blank criteria cell means, and how a criteria expression is parsed — is identical for all twelve database functions and is explained once in the criteria-range mechanism.

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; the first row is the header row.
  • field — the column selector, as header text or as a 1-based column index within the database range. Required for DSUM; only DCOUNT and DCOUNTA accept an omitted field.
  • criteria — the header-plus-conditions range or array.

Argument roles and admissible values are the family's; see the shared mechanism for the full account, including the point that a criteria range with no condition rows, or with an all-blank condition row, selects every record.

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.

  • No record matches: the sum of nothing is 0. No error.
  • Matching records whose field cells are all blank or all text: also 0, by the same route. DSUM cannot distinguish "nothing matched" from "everything that matched was empty"; if you need that distinction, pair it with DCOUNT.
  • Text that looks numeric in the field column is skipped, not parsed. This is the range-scan side of the asymmetry described in coercion and lifting.
  • Logicals in the field column are skipped.
  • Arrays: inline array literals are accepted wherever ranges are, since both resolve to a grid. DSUM is not a lift kernel; array arguments are consumed whole.

Errors

ErrorCondition
#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

DSUM has no domain error of its own — no divisor, no minimum sample size. Every error it can return comes from argument shape, field resolution, or a propagated input error.

How to implement

Notes for implementers

  1. Reduction order is observable. The family declares a sequential left fold, so the accumulation runs in record order. Pairwise or reassociated summation will differ in the last bits on long or badly-scaled columns, and no compensated-summation scheme is implied.
  2. Skip, do not coerce. The scan admits only cells whose value kind is Number. Coercing "3" to 3 here would change DSUM, DCOUNT, and DAVERAGE together and in the wrong direction.
  3. Numeric criteria comparison is not exact double comparison — see the note in the shared mechanism.
  4. The zero answer is load-bearing. Returning an error for an empty selection would be a different function; several of the siblings do error there, so a shared implementation must branch on the aggregate rather than on the selection.

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.

DSUM · 1 lines · calc-func/src/catalogue/database.rs on GitHub
10 dsum "DSUM" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Sum) }

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

  • Siblings: the twelve database functions, sharing the selection mechanism and differing only in the aggregate. DCOUNT counts what DSUM adds; DPRODUCT multiplies it; DAVERAGE is DSUM over DCOUNT except at the empty-selection boundary, where DSUM returns 0 and DAVERAGE returns #DIV/0!.
  • Nearest modern equivalent: SUMIFS (and SUMIF), which take conditions as inline arguments rather than as a worksheet-resident criteria table. Neither supersedes the other; Excel supports both.
  • Confused with: SUM (no selection stage), SUMPRODUCT (often used to emulate criteria arithmetically), and SUBTOTAL, which filters by hidden rows rather than by criteria.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents