Database functions
DCOUNT
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 | DCOUNT |
| Bulgarian | DCOUNT |
| Czech | DPOČET |
| Danish | DTÆL |
| German | DCOUNT |
| Greek | DCOUNT |
| English (Australia) | DCOUNT |
| English (United Kingdom) | DCOUNT |
| English (United States) | DCOUNT |
| Spanish | BDCONTAR |
| Estonian | DCOUNT |
| Finnish | TLASKE |
| French | BDNB |
| Hebrew | DCOUNT |
| Croatian | DCOUNT |
| Hungarian | AB.DARAB |
| Indonesian | DCOUNT |
| Italian | DCOUNT |
| Japanese | DCOUNT |
| Korean | DCOUNT |
| Lithuanian | DCOUNT |
| Latvian | DCOUNT |
| Norwegian | DANTALL |
| Dutch | DBAANTAL |
| Polish | BD.ILE.REKORDÓW |
| Portuguese (Brazil) | DCOUNT |
| Portuguese (Portugal) | BDCONTAR |
| Romanian | DCOUNT |
| Russian | БСЧЁТ |
| Slovak | DCOUNT |
| Slovenian | DCOUNT |
| Serbian (Latin) | DCOUNT |
| Swedish | DANTAL |
| Thai | DCOUNT |
| Turkish | VSEÇSAY işlevi |
| Ukrainian | DCOUNT |
| Vietnamese | DCOUNT |
| Chinese (Simplified) | DCOUNT |
| Chinese (Hong Kong) | DCOUNT |
| Chinese (Traditional) | DCOUNT |
Names from Microsoft's support site.
What it does
DCOUNT(database, field, criteria)
DCOUNT(database, field, criteria) selects the records of database that satisfy criteria
and returns how many of them hold a number in the column named by field.
With R the set of selected record rows and c the resolved field column:
result = | { r in R : value of cell (r, c) is a Number } |
If field is omitted, the column stage disappears and the function returns |R| — the count of
matching records, regardless of what any column contains. That two-mode behaviour is what makes
DCOUNT the family's record counter as well as its value counter.
"Is a Number" is a test on the value kind, not a parse. Text that reads as a number is not counted; neither are logicals, blanks, or empty strings.
The selection stage — header matching, AND across a criteria row, OR down the rows, blank criteria cells, 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 argument slots; the reference implementation declares an arity of exactly 3.
database— the header-plus-records range or array.criteria— the header-plus-conditions range or array.
Try it
Quirks
Result and edge cases
Returns a Number — a count, so always a non-negative integer.
- No record matches:
0.DCOUNTnever errors on an empty selection. - Field omitted: the result is the number of matching records. Combined with an all-blank criteria row (which selects everything), this degenerates to the record count of the database.
- Text that looks numeric in the field column is not counted. This is the range-scan side of the asymmetry in coercion and lifting.
- Logicals and blanks in the field column are not counted.
- Arrays: inline array literals resolve to grids and are accepted;
DCOUNTis not a lift kernel.
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; a supplied 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
- Two code paths, one function. The omitted-field mode short-circuits before any column is read, so a bad field value cannot be diagnosed in that mode — there is nothing to diagnose. Resolve the field only when one was supplied.
- Distinguish Missing from Empty carefully. Both are treated as "omitted" here, but they arrive by different routes (an empty call slot versus a reference to a blank cell), and the call model keeps them distinct on purpose. An implementation that collapses them upstream loses the ability to make them differ later if evidence says they should.
- Count by value kind, not by convertibility. The whole difference between
DCOUNTandDCOUNTAlives in this predicate. - Numeric criteria comparison is not exact double comparison — see the note in the shared mechanism.
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.
DCOUNT · 1 lines · calc-func/src/catalogue/database.rs on GitHub2 dcount "DCOUNT" (3, 3) [R "database", V "field", R "criteria"] |s, a, sv| { database(s, a, sv, Kind::Count) }
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
DCOUNTAis the sibling that counts non-blank cells instead of numeric ones. The pair mirrorsCOUNTandCOUNTAexactly:DCOUNTcounts numbers,DCOUNTAcounts anything present. Both accept an omitted field; no other family member does.- DSUM and DAVERAGE run over the same value list.
DAVERAGEisDSUMdivided byDCOUNTexcept when the count is zero, whereDAVERAGEreturns#DIV/0!andDCOUNTreturns0. - Nearest modern equivalent:
COUNTIFS(andCOUNTIF), which take conditions inline instead of as a criteria table. Neither supersedes the other. - Confused with:
COUNT(no selection stage) andDCOUNTA; and, when the field is omitted, withROWS, which counts rows without any selection at all.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents