{
  "category": "Database functions",
  "display_name": "DCOUNT",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.DCOUNT",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 3 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 3 recorded answers",
    "workbook_corpus": {
      "cells": 3,
      "matched": 3
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/database.rs#L265-L265"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/aggregate::reader",
        "catalogue/aggregate::read_reference",
        "catalogue/comparison::numbers",
        "catalogue/comparison::in_band",
        "catalogue/comparison::Rounded::up",
        "catalogue/comparison::Roundings::of",
        "catalogue/comparison::Roundings::disjoint",
        "catalogue/comparison::texts",
        "catalogue/comparison/collation::compare",
        "catalogue/comparison/collation::weighed",
        "catalogue/comparison/collation::measured_iteration_extension",
        "catalogue/comparison/sort_key::table",
        "catalogue/comparison/sort_key::decode64",
        "catalogue/comparison/sort_key::Reader::byte",
        "catalogue/comparison/sort_key::Reader::varint",
        "catalogue/comparison/sort_key::Reader::done",
        "catalogue/comparison/sort_key::in_ranges",
        "catalogue/comparison/sort_key::build",
        "catalogue/comparison/sort_key::han_base",
        "catalogue/comparison/sort_key::derive",
        "catalogue/comparison/sort_key::shared_jamo_tails",
        "catalogue/comparison/sort_key::ordinary_jamo_prefix",
        "catalogue/comparison/sort_key::independent_jamo_suffix",
        "catalogue/comparison/sort_key::jamo_leading_primary",
        "catalogue/comparison/sort_key::leading_order",
        "catalogue/comparison/sort_key::Before::separate_special",
        "catalogue/comparison/sort_key::Gathered::kana",
        "catalogue/comparison/sort_key::Gathered::unit",
        "catalogue/comparison/sort_key::parts",
        "catalogue/comparison/sort_key::diacritic_order",
        "catalogue/comparison/sort_key::diacritics",
        "catalogue/conditional::range",
        "catalogue/conditional::row",
        "catalogue/conditional::offset",
        "catalogue/conditional::read_range",
        "catalogue/conditional::verdicts",
        "catalogue/conditional::used",
        "catalogue/conditional::Match::of",
        "catalogue/conditional::Match::negated",
        "catalogue/conditional::Op::holds",
        "catalogue/conditional::Op::is_equality",
        "catalogue/conditional::spells",
        "catalogue/conditional::criterion",
        "catalogue/conditional::database_criterion",
        "catalogue/conditional::rank",
        "catalogue/conditional::criterion_text",
        "catalogue/conditional::decided",
        "catalogue/conditional::Criterion::verdict",
        "catalogue/conditional::equality",
        "catalogue/conditional::is_surrogate",
        "catalogue/conditional::wildcard",
        "catalogue/database::label",
        "catalogue/database::same_label",
        "catalogue/database::field",
        "catalogue/database::matching",
        "catalogue/database::criterion_verdict",
        "catalogue/database::database",
        "catalogue/database::published",
        "decimal::low32",
        "decimal::Natural::from_u64",
        "decimal::Natural::pow10",
        "decimal::Natural::normalize",
        "decimal::Natural::is_zero",
        "decimal::Natural::mul_add_small",
        "decimal::Natural::times_pow10",
        "decimal::Natural::times_pow5",
        "decimal::Natural::times_pow2",
        "decimal::ExactDecimal::binary",
        "ported/excel_numeric::excel_sqrt_staged",
        "ported/text_kernels::text",
        "ported/text_kernels::text_from_str",
        "ported/text_kernels::fold_unit",
        "ported/text_kernels::push_singleton_or_original",
        "ported/text_kernels::push_lower",
        "ported/text_kernels::lower",
        "ported/variance_common::variance_from_values",
        "ported/variance_common::stdev_from_values"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/database.rs#L265-L265",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 3 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.DCOUNT.json",
  "name": "DCOUNT",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **`DCOUNTA`** is the sibling that counts *non-blank* cells instead of numeric ones. The pair\n  mirrors `COUNT` and `COUNTA` exactly: `DCOUNT` counts numbers, `DCOUNTA` counts anything\n  present. Both accept an omitted field; no other family member does.\n- **[DSUM](FUNC.DSUM.md) and [DAVERAGE](FUNC.DAVERAGE.md)** run over the same value list.\n  `DAVERAGE` is `DSUM` divided by `DCOUNT` except when the count is zero, where `DAVERAGE`\n  returns `#DIV/0!` and `DCOUNT` returns `0`.\n- **Nearest modern equivalent**: `COUNTIFS` (and `COUNTIF`), which take conditions inline\n  instead of as a criteria table. Neither supersedes the other.\n- **Confused with**: `COUNT` (no selection stage) and `DCOUNTA`; and, when the field is omitted,\n  with `ROWS`, which counts rows without any selection at all.\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n\n1. **Two code paths, one function.** The omitted-field mode short-circuits before any column is\n   read, so a bad *field* value cannot be diagnosed in that mode — there is nothing to diagnose.\n   Resolve the field only when one was supplied.\n2. **Distinguish Missing from Empty carefully.** Both are treated as \"omitted\" here, but they\n   arrive by different routes (an empty call slot versus a reference to a blank cell), and the\n   call model keeps them distinct on purpose. An implementation that collapses them upstream\n   loses the ability to make them differ later if evidence says they should.\n3. **Count by value kind, not by convertibility.** The whole difference between `DCOUNT` and\n   `DCOUNTA` lives in this predicate.\n4. **Numeric criteria comparison is not exact double comparison** — see the note in\n   [the shared mechanism](FUNC.DAVERAGE.md#numeric-comparison-is-not-exact-double-comparison).\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns a Number — a count, so always a non-negative integer.\n\n- **No record matches**: `0`. `DCOUNT` never errors on an empty selection.\n- **Field omitted**: the result is the number of matching records. Combined with an all-blank\n  criteria row (which selects everything), this degenerates to the record count of the database.\n- **Text that looks numeric in the field column** is not counted. This is the range-scan side of\n  the asymmetry in\n  [coercion and lifting](../model/02-coercion-and-lifting.md#direct-arguments-versus-range-scans).\n- **Logicals and blanks in the field column** are not counted.\n- **Arrays**: inline array literals resolve to grids and are accepted; `DCOUNT` is not a lift\n  kernel.\n\n\n\n### Errors\n\n\n| Error | Condition |\n|---|---|\n| `#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 |\n| propagated | An error value in a header cell, a criteria cell, or a scanned field cell surfaces as that error |\n\n",
    "sources": "- Microsoft, \"DCOUNT function\" —\n  <https://support.microsoft.com/en-us/office/dcount-function-c1fc7b93-fb0d-4d8d-97db-8d5f076eaeb1>\n- Handbook `CHARTER.md` sections 1, 3 and 7; `content/model/06-claim-language.md`.\n- Handbook call-model chapters 01, 02 and 03 (Missing versus Empty, range-scan coercion, error\n  folding).\n- [DAVERAGE](FUNC.DAVERAGE.md) — the family's shared criteria-range mechanism.\n- `data/functions/FUNC.DCOUNT.json`, `data/presence/FUNC.DCOUNT.json`.\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`DCOUNT(database, field, criteria)` selects the records of *database* that satisfy *criteria*\nand returns how many of them hold a **number** in the column named by *field*.\n\nWith R the set of selected record rows and c the resolved field column:\n\n    result = | { r in R : value of cell (r, c) is a Number } |\n\nIf *field* is omitted, the column stage disappears and the function returns `|R|` — the count of\nmatching records, regardless of what any column contains. That two-mode behaviour is what makes\n`DCOUNT` the family's record counter as well as its value counter.\n\n\"Is a Number\" is a test on the value kind, not a parse. Text that reads as a number is not\ncounted; neither are logicals, blanks, or empty strings.\n\nThe selection stage — header matching, AND across a criteria row, OR down the rows, blank\ncriteria cells, and how a criteria expression is parsed — is identical for all twelve database\nfunctions and is explained once in\n[the criteria-range mechanism](FUNC.DAVERAGE.md#the-criteria-range-mechanism).\n\n\n\n### Arguments\n\n\nThree argument slots; the reference implementation declares an arity of exactly 3.\n\n- **`database`** — the header-plus-records range or array.\n- **`criteria`** — the header-plus-conditions range or array.\n\n\n"
  },
  "signature": {
    "display": "DCOUNT(database, field, criteria)",
    "parameters": [
      {
        "description": null,
        "name": "database",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "field",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "criteria",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 3
      },
      "category": "Database functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "ReductionFold",
        "fec_dependency_profile": "RefOnly",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "How many numbers a database column holds in the records that match the criteria",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Counts the cells that contain numbers in a database",
        "microsoft_url": "https://support.microsoft.com/en-us/office/dcount-function-c1fc7b93-fb0d-4d8d-97db-8d5f076eaeb1"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "DCOUNT"
        },
        {
          "locale": "bg-BG",
          "name": "DCOUNT"
        },
        {
          "locale": "cs-CZ",
          "name": "DPOČET"
        },
        {
          "locale": "da-DK",
          "name": "DTÆL"
        },
        {
          "locale": "de-DE",
          "name": "DCOUNT"
        },
        {
          "locale": "el-GR",
          "name": "DCOUNT"
        },
        {
          "locale": "en-AU",
          "name": "DCOUNT"
        },
        {
          "locale": "en-GB",
          "name": "DCOUNT"
        },
        {
          "locale": "en-US",
          "name": "DCOUNT"
        },
        {
          "locale": "es-ES",
          "name": "BDCONTAR"
        },
        {
          "locale": "et-EE",
          "name": "DCOUNT"
        },
        {
          "locale": "fi-FI",
          "name": "TLASKE"
        },
        {
          "locale": "fr-FR",
          "name": "BDNB*"
        },
        {
          "locale": "he-IL",
          "name": "DCOUNT"
        },
        {
          "locale": "hr-HR",
          "name": "DCOUNT"
        },
        {
          "locale": "hu-HU",
          "name": "AB.DARAB"
        },
        {
          "locale": "id-ID",
          "name": "DCOUNT"
        },
        {
          "locale": "it-IT",
          "name": "DCOUNT"
        },
        {
          "locale": "ja-JP",
          "name": "DCOUNT"
        },
        {
          "locale": "ko-KR",
          "name": "DCOUNT"
        },
        {
          "locale": "lt-LT",
          "name": "DCOUNT"
        },
        {
          "locale": "lv-LV",
          "name": "DCOUNT"
        },
        {
          "locale": "nb-NO",
          "name": "DANTALL"
        },
        {
          "locale": "nl-NL",
          "name": "DBAANTAL"
        },
        {
          "locale": "pl-PL",
          "name": "BD.ILE.REKORDÓW"
        },
        {
          "locale": "pt-BR",
          "name": "DCOUNT"
        },
        {
          "locale": "pt-PT",
          "name": "BDCONTAR"
        },
        {
          "locale": "ro-RO",
          "name": "DCOUNT"
        },
        {
          "locale": "ru-RU",
          "name": "БСЧЁТ"
        },
        {
          "locale": "sk-SK",
          "name": "DCOUNT"
        },
        {
          "locale": "sl-SI",
          "name": "DCOUNT"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "DCOUNT"
        },
        {
          "locale": "sv-SE",
          "name": "DANTAL"
        },
        {
          "locale": "th-TH",
          "name": "DCOUNT"
        },
        {
          "locale": "tr-TR",
          "name": "VSEÇSAY işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "DCOUNT"
        },
        {
          "locale": "vi-VN",
          "name": "DCOUNT"
        },
        {
          "locale": "zh-CN",
          "name": "DCOUNT"
        },
        {
          "locale": "zh-HK",
          "name": "DCOUNT"
        },
        {
          "locale": "zh-TW",
          "name": "DCOUNT"
        }
      ],
      "signature": {
        "display": "DCOUNT(database, field, criteria)",
        "parameters": [
          {
            "description": null,
            "name": "database",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "field",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "criteria",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "DCOUNT",
      "version_marker": null,
      "xlcall": {
        "code": "40",
        "symbol": "xlfDcount"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/dcount-function-c1fc7b93-fb0d-4d8d-97db-8d5f076eaeb1"
  },
  "try_it": {
    "formula": "=DCOUNT(B2:D6,\"Amount\",F2:F3)",
    "inputs": {
      "B2": "Name",
      "B3": "A",
      "B4": "B",
      "B5": "C",
      "B6": "D",
      "C2": "Group",
      "C3": "East",
      "C4": "East",
      "C5": "West",
      "C6": "East",
      "D2": "Amount",
      "D3": 10,
      "D4": 20,
      "D5": 30,
      "D6": 40,
      "F2": "Group",
      "F3": "East"
    }
  },
  "url": "https://handbook.dnacalc.com/functions/DCOUNT.html",
  "variants": [],
  "versions": []
}