{
  "category": "Our 10 featured functions",
  "display_name": "COUNTIFS",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COUNTIFS",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 14 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 14 recorded answers",
    "workbook_corpus": {
      "cells": 15,
      "matched": 14,
      "pending": 1
    }
  },
  "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/conditional.rs#L166-L166",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/conditional.rs#L194-L204"
      ],
      "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::conditional",
        "catalogue/conditional::Range::shape",
        "catalogue/conditional::range",
        "catalogue/conditional::pairs",
        "catalogue/conditional::Plan::read_conditions",
        "catalogue/conditional::row",
        "catalogue/conditional::count",
        "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::rank",
        "catalogue/conditional::criterion_text",
        "catalogue/conditional::decided",
        "catalogue/conditional::Criterion::verdict",
        "catalogue/conditional::equality",
        "catalogue/conditional::is_surrogate",
        "catalogue/conditional::wildcard",
        "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/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"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/conditional.rs#L166-L166",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 14 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COUNTIFS.json",
  "name": "COUNTIFS",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[COUNTIF](FUNC.COUNTIF.md) handles one condition; [SUMIFS](FUNC.SUMIFS.md) sums matching amounts; [FILTER](FUNC.FILTER.md) exposes the matching records.\n\n\n",
    "how-to-implement": "\n1. Validate the argument pairs and resolve all range references. Check row and column dimensions before reading criteria or range values, preserving the current error order.\n2. Read each criterion once and compile the typed [COUNTIF predicate](FUNC.COUNTIF.md#how-to-implement): operator, operand kind and any wildcard tokens.\n3. Align ranges by offset inside their own rectangles. At a position, combine every predicate’s verdict with AND. A known false verdict rules that position out; do not add independent per-range counts.\n4. Increment once for each position satisfying all conditions. Return one numeric count after visiting the aligned positions.\n\nIn the main example, B2/C2 fails the amount condition, B3/C3 passes both, B4/C4 fails, and B5/C5 passes both, giving two. For the interval example, seven and eleven pass both tests.\n\nThe current sparse implementation keeps verdicts for visited cells and counts matching blank positions in bulk, so whole-column references need not allocate a Boolean entry for every worksheet cell. It preserves unresolved verdicts and refuses only when one can affect the count. Copying its supported predicates is an implementation route; the explicitly unmodeled text, array and collation cases still need evidence before coverage can be extended.\n\n\n",
    "quirks": "\nEvery criteria range must have the same row and column dimensions as the first. Equal total cell counts in different shapes are not enough. The current implementation returns `#VALUE!` for a shape mismatch before reading any criterion.\n\nConditions on the same range still use AND. For example, `\">=7\"` and `\"<=11\"` define an inclusive interval; the pair `\">=10\"` and `\"<5\"` cannot match one numeric value. For OR, count a union without double-counting its overlap.\n\nA criterion referencing an empty cell is treated as zero. This does not make every blank tested cell equivalent to zero under every predicate. Text criteria retain case-insensitive matching and `?`, `*`, `~` wildcard syntax; preserve leading and trailing spaces when their presence is meaningful.\n\n\n",
    "sources": "\n- [Microsoft: COUNTIFS function](https://support.microsoft.com/en-us/excel/functions/countifs-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc criteria grammar, range validation and count planning](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/catalogue/conditional.rs); implementation rules and its explicit unsupported cases.\n\n",
    "try-it": "\nUse these four rows:\n\n| Row | B: amount | C: region |\n|---:|---:|---|\n| 2 | 4 | east |\n| 3 | 11 | east |\n| 4 | 7 | west |\n| 5 | 13 | east |\n\n`=COUNTIFS(B2:B5,\">=10\",C2:C5,\"east\")` returns `2`, for rows three and five. Repeating a range creates an interval: `=COUNTIFS(B2:B5,\">=7\",B2:B5,\"<=11\")` returns `2`.\n\nAdding separate counts implements an OR only when overlap is handled. Here `COUNTIF(B2:B5,\">=10\")+COUNTIF(C2:C5,\"east\")` is five, because rows three and five are counted twice. Subtract their intersection, the first COUNTIFS result, to get three distinct rows meeting either condition.\n\n\n",
    "version-differences": "\nNo same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.\n\n\n",
    "what-it-does": "\n`COUNTIFS(criteria_range1,criteria1,[criteria_range2,criteria2],...)` counts positions where **all** paired conditions hold. It combines conditions with AND. Up to 127 range/criterion pairs are documented. The ranges align by their row and column offsets and need not be adjacent on the sheet.\n\n\n"
  },
  "signature": {
    "display": "COUNTIFS(criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "criteria_range1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "criteria1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "criteria_range2",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "criteria2",
        "optional": true,
        "repeats": true
      }
    ],
    "trailing_repeats": true
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 254,
        "min": 2
      },
      "category": "Our 10 featured 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 cells meet every one of several conditions",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Use this function to count the number of cells within a range that meet multiple criteria.",
        "microsoft_url": "https://support.microsoft.com/en-us/office/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COUNTIFS"
        },
        {
          "locale": "bg-BG",
          "name": "COUNTIFS"
        },
        {
          "locale": "cs-CZ",
          "name": "COUNTIFS"
        },
        {
          "locale": "da-DK",
          "name": "TÆL.HVISER"
        },
        {
          "locale": "de-DE",
          "name": "COUNTIFS"
        },
        {
          "locale": "el-GR",
          "name": "COUNTIFS"
        },
        {
          "locale": "en-AU",
          "name": "COUNTIFS"
        },
        {
          "locale": "en-GB",
          "name": "COUNTIFS"
        },
        {
          "locale": "en-US",
          "name": "COUNTIFS"
        },
        {
          "locale": "es-ES",
          "name": "CONTAR.SI.CONJUNTO"
        },
        {
          "locale": "et-EE",
          "name": "COUNTIFS"
        },
        {
          "locale": "fi-FI",
          "name": "LASKE.JOS.JOUKKO"
        },
        {
          "locale": "fr-FR",
          "name": "NB.SI.ENS*"
        },
        {
          "locale": "he-IL",
          "name": "COUNTIFS"
        },
        {
          "locale": "hr-HR",
          "name": "COUNTIFS"
        },
        {
          "locale": "hu-HU",
          "name": "DARABHATÖBB"
        },
        {
          "locale": "id-ID",
          "name": "COUNTIFS"
        },
        {
          "locale": "it-IT",
          "name": "COUNTIFS"
        },
        {
          "locale": "ja-JP",
          "name": "COUNTIFS"
        },
        {
          "locale": "ko-KR",
          "name": "COUNTIFS"
        },
        {
          "locale": "lt-LT",
          "name": "COUNTIFS"
        },
        {
          "locale": "lv-LV",
          "name": "COUNTIFS"
        },
        {
          "locale": "nb-NO",
          "name": "ANTALL.HVIS, ANTALL.HVIS.SETT"
        },
        {
          "locale": "nl-NL",
          "name": "AANTALLEN.ALS"
        },
        {
          "locale": "pl-PL",
          "name": "LICZ.WARUNKI"
        },
        {
          "locale": "pt-BR",
          "name": "COUNTIFS"
        },
        {
          "locale": "pt-PT",
          "name": "CONTAR.SE.S"
        },
        {
          "locale": "ro-RO",
          "name": "COUNTIFS"
        },
        {
          "locale": "ru-RU",
          "name": "СЧЁТЕСЛИМН"
        },
        {
          "locale": "sk-SK",
          "name": "COUNTIFS"
        },
        {
          "locale": "sl-SI",
          "name": "COUNTIFS"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COUNTIFS"
        },
        {
          "locale": "sv-SE",
          "name": "ANTAL.OMF"
        },
        {
          "locale": "th-TH",
          "name": "COUNTIFS"
        },
        {
          "locale": "tr-TR",
          "name": "ÇOKEĞERSAY işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "COUNTIFS"
        },
        {
          "locale": "vi-VN",
          "name": "COUNTIFS"
        },
        {
          "locale": "zh-CN",
          "name": "COUNTIFS"
        },
        {
          "locale": "zh-HK",
          "name": "COUNTIFS"
        },
        {
          "locale": "zh-TW",
          "name": "COUNTIFS"
        }
      ],
      "signature": {
        "display": "COUNTIFS(criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "criteria_range1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "criteria1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "criteria_range2",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "criteria2",
            "optional": true,
            "repeats": true
          }
        ],
        "trailing_repeats": true
      },
      "surface_name": "COUNTIFS",
      "version_marker": null,
      "xlcall": {
        "code": "481",
        "symbol": "xlfCountifs"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842"
  },
  "try_it": {
    "formula": "=COUNTIFS(B2:B5,\">=10\",C2:C5,\"east\")",
    "inputs": {
      "B2": 4,
      "B3": 11,
      "B4": 7,
      "B5": 13,
      "C2": "east",
      "C3": "east",
      "C4": "west",
      "C5": "east"
    }
  },
  "url": "https://handbook.dnacalc.com/functions/COUNTIFS.html",
  "variants": [],
  "versions": []
}