{
  "category": "Database functions",
  "display_name": "DSTDEV",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.DSTDEV",
  "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#L271-L271"
      ],
      "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#L271-L271",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 3 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.DSTDEV.json",
  "name": "DSTDEV",
  "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- **[DSTDEVP](FUNC.DSTDEVP.md)** is the population form: divisor n, and one value is enough.\n- **[DVAR](FUNC.DVAR.md)** is the square of this function, and the page that carries the shared\n  numerical discussion.\n- **Nearest modern equivalent**: `STDEV.S` over a filtered array. Excel's compatibility rename\n  pass produced `STDEV` / `STDEV.S`; the database family was not renamed, so `DSTDEV` is not a\n  deprecated name and has no `.S`-suffixed replacement.\n- **Confused with**: `DSTDEVP` (the divisor and the minimum count) and `STDEVA`, which counts\n  logicals and text.\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n\n1. **Compose, do not reformulate.** Computing the variance and taking its square root is what\n   the reference implementation does; a more accurate direct route is a different function in\n   the last bits.\n2. **Guard the count before the arithmetic.** `#DIV/0!` at n < 2 is a domain decision.\n3. **Both accumulation passes are sequential left folds** in record order, per the family's\n   declared reduction policy.\n4. **Skip, do not coerce.** Admit only cells whose value kind is Number.\n5. **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, non-negative.\n\n- **Fewer than two numeric values selected**: `#DIV/0!` — the error comes from the variance\n  stage, before any square root is attempted.\n- **All selected values equal**: `0`, exactly, since the variance is exactly zero and √0 is 0.\n- **Text that looks numeric in the field column** is skipped, per the range-scan side of the\n  asymmetry in\n  [coercion and lifting](../model/02-coercion-and-lifting.md#direct-arguments-versus-range-scans).\n- **Logicals in the field column** are skipped.\n- **Arrays**: inline array literals resolve to grids and are accepted; `DSTDEV` is not a lift\n  kernel.\n- **No negative-argument path.** Because the two-pass variance cannot be negative, the square\n  root has no domain failure. An implementation using the sum-of-squares form could produce a\n  negative variance and hence a `#NUM!` from the root — an error `DSTDEV` should never be able\n  to return.\n\n\n\n### Errors\n\n\n| Error | Condition |\n|---|---|\n| `#DIV/0!` | Fewer than two numeric values were collected from the field column of the matching records |\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; *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, \"DSTDEV function\" —\n  <https://support.microsoft.com/en-us/office/dstdev-function-026b8c73-616d-4b5e-b072-241871c4ab96>\n- Handbook `CHARTER.md` sections 1, 3 and 7; `content/model/06-claim-language.md`.\n- Handbook call-model chapters 02 and 03 (range-scan coercion, error folding, precision\n  publication).\n- [DAVERAGE](FUNC.DAVERAGE.md) — the family's shared criteria-range mechanism;\n  [DVAR](FUNC.DVAR.md) — the shared numerical account of the variance formula.\n- `data/functions/FUNC.DSTDEV.json`, `data/presence/FUNC.DSTDEV.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`DSTDEV(database, field, criteria)` selects the records of *database* that satisfy *criteria*,\nreads the column named by *field*, and returns the **sample** standard deviation of the numeric\nvalues found there.\n\nWith V = [ v₁ … vₙ ] the Numbers collected from the field column of the matching records, in\nrecord order, and n = |V|:\n\n    x̄ = (Σ vᵢ) / n\n    s  = √( Σ (vᵢ − x̄)² / (n − 1) )\n\nOperationally it is [DVAR](FUNC.DVAR.md) followed by one square root; the reference\nimplementation computes it exactly that way. Sample semantics mean the divisor is n − 1 and at\nleast two numeric values are required.\n\nNon-numeric cells in the field column — text, logicals, blanks — are skipped, so n counts\nnumbers, not records.\n\nThe selection stage — header matching, AND across a criteria row, OR down the rows, blank\ncriteria cells, and criteria-expression parsing — is identical for all twelve database functions\nand is explained once in\n[the criteria-range mechanism](FUNC.DAVERAGE.md#the-criteria-range-mechanism).\n\n### The extra rounding step\n\n`DSTDEV` is not a single rounded operation. The variance is computed and rounded to a double,\nand *then* the square root of that rounded value is taken and rounded again. The result is\ntherefore not in general the correctly rounded standard deviation of the input data: two\nroundings sit between the exact answer and the published one. IEEE-754 square root is itself\ncorrectly rounded, so the discrepancy comes entirely from the intermediate — which means an\nimplementation that computed s directly, more accurately, would *differ* from the composed\nroute on some inputs. Matching a composed route is a compatibility target, not an accuracy\ntarget, and the Handbook has not established which route Excel takes.\n\n\n\n### Arguments\n\n\nThree arguments, all required at the call site; the reference implementation declares an arity\nof exactly 3.\n\n- **`database`** — the header-plus-records range or array.\n- **`field`** — the column selector, as header text or as a 1-based column index within the\n  database range. Required.\n- **`criteria`** — the header-plus-conditions range or array.\n\n\n"
  },
  "signature": {
    "display": "DSTDEV(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": "Sample standard deviation of a database column over the matching records",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Estimates the standard deviation based on a sample of selected database entries",
        "microsoft_url": "https://support.microsoft.com/en-us/office/dstdev-function-026b8c73-616d-4b5e-b072-241871c4ab96"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "DSTDEV"
        },
        {
          "locale": "bg-BG",
          "name": "DSTDEV"
        },
        {
          "locale": "cs-CZ",
          "name": "DSMODCH.VÝBĚR"
        },
        {
          "locale": "da-DK",
          "name": "DSTDAFV"
        },
        {
          "locale": "de-DE",
          "name": "DSTDEV"
        },
        {
          "locale": "el-GR",
          "name": "DSTDEV"
        },
        {
          "locale": "en-AU",
          "name": "DSTDEV"
        },
        {
          "locale": "en-GB",
          "name": "DSTDEV"
        },
        {
          "locale": "en-US",
          "name": "DSTDEV"
        },
        {
          "locale": "es-ES",
          "name": "BDDESVEST"
        },
        {
          "locale": "et-EE",
          "name": "DSTDEV"
        },
        {
          "locale": "fi-FI",
          "name": "TKESKIHAJONTA"
        },
        {
          "locale": "fr-FR",
          "name": "BDECARTYPE*"
        },
        {
          "locale": "he-IL",
          "name": "DSTDEV"
        },
        {
          "locale": "hr-HR",
          "name": "DSTDEV"
        },
        {
          "locale": "hu-HU",
          "name": "AB.SZÓRÁS"
        },
        {
          "locale": "id-ID",
          "name": "DSTDEV"
        },
        {
          "locale": "it-IT",
          "name": "DSTDEV"
        },
        {
          "locale": "ja-JP",
          "name": "DSTDEV"
        },
        {
          "locale": "ko-KR",
          "name": "DSTDEV"
        },
        {
          "locale": "lt-LT",
          "name": "DSTDEV"
        },
        {
          "locale": "lv-LV",
          "name": "DSTDEV"
        },
        {
          "locale": "nb-NO",
          "name": "DSTDAV"
        },
        {
          "locale": "nl-NL",
          "name": "DBSTDEV"
        },
        {
          "locale": "pl-PL",
          "name": "BD.ODCH.STANDARD"
        },
        {
          "locale": "pt-BR",
          "name": "DSTDEV"
        },
        {
          "locale": "pt-PT",
          "name": "BDDESVPAD"
        },
        {
          "locale": "ro-RO",
          "name": "DSTDEV"
        },
        {
          "locale": "ru-RU",
          "name": "ДСТАНДОТКЛ"
        },
        {
          "locale": "sk-SK",
          "name": "DSTDEV"
        },
        {
          "locale": "sl-SI",
          "name": "DSTDEV"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "DSTDEV"
        },
        {
          "locale": "sv-SE",
          "name": "DSTDAV"
        },
        {
          "locale": "th-TH",
          "name": "DSTDEV"
        },
        {
          "locale": "tr-TR",
          "name": "VSEÇSTDSAPMA işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "DSTDEV"
        },
        {
          "locale": "vi-VN",
          "name": "DSTDEV"
        },
        {
          "locale": "zh-CN",
          "name": "DSTDEV"
        },
        {
          "locale": "zh-HK",
          "name": "DSTDEV"
        },
        {
          "locale": "zh-TW",
          "name": "DSTDEV"
        }
      ],
      "signature": {
        "display": "DSTDEV(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": "DSTDEV",
      "version_marker": null,
      "xlcall": {
        "code": "45",
        "symbol": "xlfDstdev"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/dstdev-function-026b8c73-616d-4b5e-b072-241871c4ab96"
  },
  "try_it": {
    "formula": "=DSTDEV(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/DSTDEV.html",
  "variants": [],
  "versions": []
}