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
| Language | Name in Excel |
|---|---|
| Arabic | DSUM |
| Bulgarian | DSUM |
| Czech | DSUMA |
| Danish | DSUM |
| German | DSUM |
| Greek | DSUM |
| English (Australia) | DSUM |
| English (United Kingdom) | DSUM |
| English (United States) | DSUM |
| Spanish | BDSUMA |
| Estonian | DSUM |
| Finnish | TSUMMA |
| French | BDSOMME |
| Hebrew | DSUM |
| Croatian | DSUM |
| Hungarian | AB.SZUM |
| Indonesian | DSUM |
| Italian | DSUM |
| Japanese | DSUM |
| Korean | DSUM |
| Lithuanian | DSUM |
| Latvian | DSUM |
| Norwegian | DSUM |
| Dutch | DBSOM |
| Polish | BD.SUMA |
| Portuguese (Brazil) | DSUM |
| Portuguese (Portugal) | BDSOMA |
| Romanian | DSUM |
| Russian | БДСУММ |
| Slovak | DSUM |
| Slovenian | DSUM |
| Serbian (Latin) | DSUM |
| Swedish | DSUMMA |
| Thai | DSUM |
| Turkish | VSEÇTOPLA işlevi |
| Ukrainian | DSUM |
| Vietnamese | DSUM |
| 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 forDSUM; 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
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.DSUMcannot 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.
DSUMis not a lift kernel; array arguments are consumed whole.
Errors
| Error | Condition |
|---|---|
#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 |
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
- 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.
- Skip, do not coerce. The scan admits only cells whose value kind is Number. Coercing
"3"to 3 here would changeDSUM,DCOUNT, andDAVERAGEtogether and in the wrong direction. - Numeric criteria comparison is not exact double comparison — see the note in the shared mechanism.
- 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 GitHub10 dsum "DSUM" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Sum) }
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
- Siblings: the twelve database functions, sharing the selection mechanism and differing
only in the aggregate. DCOUNT counts what
DSUMadds; DPRODUCT multiplies it; DAVERAGE isDSUMoverDCOUNTexcept at the empty-selection boundary, whereDSUMreturns0andDAVERAGEreturns#DIV/0!. - Nearest modern equivalent:
SUMIFS(andSUMIF), 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), andSUBTOTAL, 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