{
  "category": "Statistical functions",
  "display_name": "AVERAGEIFS",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.AVERAGEIFS",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 13 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 13 recorded answers",
    "workbook_corpus": {
      "cells": 13,
      "matched": 13
    }
  },
  "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#L170-L176",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/conditional.rs#L241-L250"
      ],
      "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::total",
        "catalogue/conditional::mean",
        "catalogue/conditional::Range::shape",
        "catalogue/conditional::range",
        "catalogue/conditional::pairs",
        "catalogue/conditional::Plan::each_matched",
        "catalogue/conditional::row",
        "catalogue/conditional::offset",
        "catalogue/conditional::read_range",
        "catalogue/conditional::verdicts",
        "catalogue/conditional::target_cells",
        "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#L170-L176",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 13 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.AVERAGEIFS.json",
  "name": "AVERAGEIFS",
  "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- **[AVERAGEIF](FUNC.AVERAGEIF.md)** — the singular form, with reversed argument order and the\n  anchoring rule this function drops. The shared criteria language is documented there.\n- **`SUMIFS` / `COUNTIFS` / `MAXIFS` / `MINIFS`** — the rest of the plural family, same module,\n  same conjunction, same shape rule. `AVERAGEIFS` is `SUMIFS/COUNTIFS` only when every matched\n  cell is numeric; when a matched cell holds text the divisors differ, because `COUNTIFS`\n  counts matched positions and `AVERAGEIFS` counts matched numeric cells.\n- **`DAVERAGE`** — the database-family conditional mean. It expresses OR natively, through\n  multiple criteria rows, which is exactly what `AVERAGEIFS` cannot do; see\n  [DAVERAGE](FUNC.DAVERAGE.md).\n- **`FILTER` + `AVERAGE`**, or `AVERAGE(IF(...))` as an array formula — the routes that can\n  express disjunction and relational conditions. They use ordinary worksheet comparison, so\n  they do not inherit the wildcard language or the tolerant numeric comparison.\n- **`GROUPBY` / `PIVOTBY`** — where a whole table of conditional means is wanted rather than\n  one cell.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThe reduction is the same plain sequential `f64` accumulation and single division as\n[AVERAGE](FUNC.AVERAGE.md#numerical-notes), applied to the masked subset in row-major order.\nIts error analysis carries over unchanged: a bound proportional to \\(\\sum|x_i|\\) over the\nselected cells, and order sensitivity.\n\nTwo things are specific to this surface.\n\n",
    "quirks": "\n### Differences from AVERAGEIF that are not just \"more criteria\"\n\n\n| | `AVERAGEIF` | `AVERAGEIFS` |\n|---|---|---|\n| Averaged range | third argument, optional | first argument, required |\n| Shape rule | anchored: only the top-left of `average_range` matters | **exact**: every range must be the same size and shape |\n| Criteria count | exactly one | one or more, conjoined |\n| Argument structure | fixed 2–3 | first argument plus range/criterion pairs |\n| Documented logical rule | TRUE/FALSE cells are **ignored** | TRUE evaluates as 1, FALSE as 0 |\n\nThe documented logical rule is the row where the two Microsoft pages contradict each other; see\nthe divergences section.\n\n\n\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **No position satisfies every criterion** → `#DIV/0!`, documented: \"If there are no cells\n  that meet all the criteria, AVERAGEIFS returns the #DIV/0! error value.\"\n- **A single criterion pair.** `AVERAGEIFS(B1:B10, A1:A10, \">5\")` is the exact-shape analogue\n  of `AVERAGEIF(A1:A10, \">5\", B1:B10)`, and is the safer of the two to write precisely because\n  no anchoring can occur.\n- **Empty cells in `average_range`** contribute to neither sum nor count.\n- **Overlapping ranges**, including using `average_range` as its own criteria range, are\n  ordinary.\n- **Arrays.** The surface lifts natively (`lift_broadcast_profile: surface_native`); inline\n  array arguments are accepted but must match shape exactly, since an array carries no\n  reference to re-anchor.\n\n\n\n### Documentation divergences\n\n3. **The `#DIV0!` spelling** appears in the remark text on both pages where `#DIV/0!` is meant;\n   noted so a reader searching for the code finds the remark.\n\n\n",
    "sources": "- Microsoft, \"AVERAGEIFS function\" —\n  <https://support.microsoft.com/en-us/office/averageifs-function-48910c45-1fc0-4389-a028-f7c5c3001690>\n  (syntax and argument text; the 1-to-127 range and criteria limits; the blank-or-text `#DIV0!`\n  remark; the empty-criteria-cell-as-zero remark; the TRUE-as-1/FALSE-as-0 remark; the\n  all-criteria-true rule; the same-size-and-shape requirement contrasted with `AVERAGEIF`; the\n  cannot-be-translated-into-numbers remark; the no-cells-meet-criteria `#DIV/0!`; and the\n  wildcard set).\n- Microsoft, \"AVERAGEIF function\" —\n  <https://support.microsoft.com/en-us/office/averageif-function-faec8e2e-0dec-4308-af69-f5576d8ac642>\n  (quoted here only for the contradicting ignored-logicals remark and the anchoring statement).\n- Handbook projections `data/functions/FUNC.AVERAGEIFS.json` and\n  `data/presence/FUNC.AVERAGEIFS.json`.\n- Handbook, [AVERAGEIF](FUNC.AVERAGEIF.md) (the shared criteria language),\n  [AVERAGE](FUNC.AVERAGE.md) (the reduction's error analysis),\n  [Coercion and lifting](../model/02-coercion-and-lifting.md).\n- Handbook `CHARTER.md` sections 1, 3 and 7; `content/model/06-claim-language.md`.\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`AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)`\naverages the numeric cells of `average_range` at the positions where **every** criterion holds:\n\n    M      = { i : criteria₁(criteria_range₁[i]) ∧ … ∧ criteria_m(criteria_range_m[i]) }\n    result = ( Σ_{i ∈ M, average_range[i] numeric} average_range[i] )\n             / #{ i ∈ M : average_range[i] numeric }\n\nThe conjunction is positional, not relational: position \\(i\\) in every criteria range refers to\nthe same row of the same conceptual table as position \\(i\\) in `average_range`. This is why the\nshapes must agree, and it is why `AVERAGEIFS` cannot express a join.\n\nMicrosoft states the rule in one sentence: \"Each cell in average_range is used in the average\ncalculation only if all of the corresponding criteria specified are true for that cell.\"\n\nThere is no OR form. Disjunction has to be built as a sum of `AVERAGEIFS` results — which is\nwrong for a mean, because means do not add — or by moving to `FILTER` or `SUMPRODUCT`. That\nasymmetry (AND is a function, OR is not) is a real limitation of the whole `…IFS` family.\n\nThe criteria parsing and cell-matching stages are shared verbatim with\n[AVERAGEIF](FUNC.AVERAGEIF.md#the-criteria-mechanism), `COUNTIF(S)`, `SUMIF(S)`, `MAXIFS` and\n`MINIFS`; that section is the single description, and it is not repeated here.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Default |\n|---|---|---|\n| `average_range` | The cells actually averaged. Required, and **first**. | — |\n| `criteria_range1` | The first range tested. Required. | — |\n| `criteria1` | The first criterion. Required. | — |\n| `criteria_range2, criteria2 …` | Further range/criterion pairs. Optional, in pairs. | — |\n\nThe argument order is reversed relative to `AVERAGEIF`. In `AVERAGEIF` the tested range comes\nfirst and the averaged range is an optional third argument; in `AVERAGEIFS` the averaged range\ncomes first and is mandatory. Rewriting one as the other by adding a criterion pair silently\nproduces a different formula.\n\n\n"
  },
  "signature": {
    "display": "AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "average_range",
        "optional": false,
        "repeats": false
      },
      {
        "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": 255,
        "min": 3
      },
      "category": "Statistical 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": "Mean of the cells that meet every one of several conditions",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the average (arithmetic mean) of all cells that meet multiple criteria",
        "microsoft_url": "https://support.microsoft.com/en-us/office/averageifs-function-48910c45-1fc0-4389-a028-f7c5c3001690"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "bg-BG",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "cs-CZ",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "da-DK",
          "name": "MIDDEL.HVISER"
        },
        {
          "locale": "de-DE",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "el-GR",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "en-AU",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "en-GB",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "en-US",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "es-ES",
          "name": "PROMEDIO.SI.CONJUNTO"
        },
        {
          "locale": "et-EE",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "fi-FI",
          "name": "KESKIARVO.JOS.JOUKKO"
        },
        {
          "locale": "fr-FR",
          "name": "MOYENNE.SI.ENS*"
        },
        {
          "locale": "he-IL",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "hr-HR",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "hu-HU",
          "name": "ÁTLAGHATÖBB"
        },
        {
          "locale": "id-ID",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "it-IT",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "ja-JP",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "ko-KR",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "lt-LT",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "lv-LV",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "nb-NO",
          "name": "GJENNOMSNITTHVIS"
        },
        {
          "locale": "nl-NL",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "pl-PL",
          "name": "ŚREDNIA.WARUNKÓW"
        },
        {
          "locale": "pt-BR",
          "name": "MÉDIASES"
        },
        {
          "locale": "pt-PT",
          "name": "MÉDIA.SE.S"
        },
        {
          "locale": "ro-RO",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "ru-RU",
          "name": "СРЗНАЧЕСЛИМН"
        },
        {
          "locale": "sk-SK",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "sl-SI",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "sv-SE",
          "name": "MEDEL.OMF"
        },
        {
          "locale": "th-TH",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "tr-TR",
          "name": "ÇOKEĞERORTALAMA işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "vi-VN",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "zh-CN",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "zh-HK",
          "name": "AVERAGEIFS"
        },
        {
          "locale": "zh-TW",
          "name": "AVERAGEIFS"
        }
      ],
      "signature": {
        "display": "AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "average_range",
            "optional": false,
            "repeats": false
          },
          {
            "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": "AVERAGEIFS",
      "version_marker": null,
      "xlcall": {
        "code": "484",
        "symbol": "xlfAverageifs"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/averageifs-function-48910c45-1fc0-4389-a028-f7c5c3001690"
  },
  "try_it": {
    "formula": "=AVERAGEIFS(C2:C4,B2:B4,\">1\")",
    "inputs": {
      "B2": 1,
      "B3": 2,
      "B4": 3,
      "C2": 10,
      "C3": 20,
      "C4": 30
    }
  },
  "url": "https://handbook.dnacalc.com/functions/AVERAGEIFS.html",
  "variants": [],
  "versions": []
}