{
  "category": "Statistical functions",
  "display_name": "MAXIFS",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.MAXIFS",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 18 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 18 recorded answers",
    "workbook_corpus": {
      "cells": 18,
      "matched": 18
    }
  },
  "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#L177-L177",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/conditional.rs#L252-L262"
      ],
      "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::extreme",
        "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#L177-L177",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 18 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.MAXIFS.json",
  "name": "MAXIFS",
  "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- **[MAX](FUNC.MAX.md)** — the unconditional maximum. The two differ in more than the filter:\n  `MAX` takes a variadic value list and applies the direct-versus-scan coercion split, while\n  `MAXIFS` takes ranges only and applies the criteria family's comparison rules. They are not\n  the same reduction wearing a filter.\n- **`SUMIFS`**, **[AVERAGEIFS](FUNC.AVERAGEIFS.md)**,\n  **`COUNTIFS`** — the rest of the multi-criteria family, sharing the\n  selection stage. `COUNTIFS` with the same criteria is the standard way to distinguish \"no\n  match\" from \"the maximum is zero\".\n- **[SUMIF](FUNC.SUMIF.md)**, **[AVERAGEIF](FUNC.AVERAGEIF.md)**, **`COUNTIF`**\n  — the single-criterion ancestors, whose argument order differs (range first, then criterion,\n  then the sum range last) from the `…IFS` order (result range first). That reversal is the\n  most common editing mistake when converting between them, and it is silent when the ranges\n  happen to be the same shape.\n- **[DMAX](FUNC.DMAX.md)** — the database-family conditional maximum, using a criteria *range*\n  with headers instead of range/criterion pairs. `DMAX` can express OR, which `MAXIFS` cannot.\n- **`MAX(IF(…))`** — the legacy array-formula idiom for the same job, which uses ordinary\n  worksheet equality rather than the criteria language and therefore does **not** always agree\n  with `MAXIFS`. Where they disagree, the criteria language's comparison rules are usually the\n  reason.\n- **[FILTER](FUNC.FILTER.md)** with `MAX` — the modern dynamic-array route, which does support\n  OR and arbitrary boolean expressions, and which uses ordinary comparison operators rather\n  than criteria strings.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThe reduction half of `MAXIFS` has no arithmetic and no rounding error, exactly as\n[MAX](FUNC.MAX.md) does not. The numerical substance is entirely in the **selection** half, and\nit is genuinely substantial.\n\n**The comparison predicate is the whole story.** A numeric criterion has to decide whether a\nstored double equals, exceeds or falls below a target double. Three predicates are plausible\nand they disagree on real data:\n\n1. **Raw IEEE comparison** — `0.1+0.2 = 0.3` is FALSE, and the cell is excluded.\n2. **Truncation to 15 significant decimal digits before comparing** — the behaviour the\n   upstream defect stream `BUG-FUNC-004` records for Excel's tolerant comparison families. Under\n   this rule `0.1+0.2` and `0.3` are equal and the cell is included.\n3. **A relative-epsilon comparison** — plausible-looking, and not what the record describes.\n\nThe difference is not a last-bit matter: it changes *which cells are in the population*, and\ntherefore can change the returned maximum by an arbitrary amount. A criterion `\">=0.3\"` applied\nto a column containing `0.1+0.2` either admits a row or does not, and if that row holds the\nlargest value the two answers differ completely. **This is the reason `MAXIFS` belongs on a\nnumerical-behaviour page at all.**\n\nA second-order point: because the criteria strings are *parsed*, a criterion built by\nconcatenation — `\">=\"&A1` — goes through a number-to-text-to-number round trip. Excel's\ngeneral number formatting renders at most 15 significant digits, so a threshold that needs the\n16th or 17th digit to be represented exactly cannot survive the round trip. The safe idiom\npasses the comparison operator and the value separately where the function allows it, or uses\na helper column of booleans; the criteria language does not offer a typed alternative.\n\n**The empty-set convention.** As on `MAX`, the documented answer for no match is `0`, which is\ninside the range of plausible data rather than below it. Chained or hierarchical `MAXIFS`\ncomputations over all-negative data inherit the same associativity trap described on the\n[MAX](FUNC.MAX.md) page: the top-level answer can be `0` when every underlying value is\nnegative.\n\n\n",
    "quirks": "\n### The criteria language\n\n\nThe criteria argument is the family's shared mini-language, and Microsoft's page says so\nexplicitly: the same criteria format works across `MINIFS`, `SUMIFS` and `AVERAGEIFS`. The\nHandbook documents the language once, on the criteria-family pages; the parts that bear on\n`MAXIFS` specifically are:\n\n- A bare number or text is an equality test.\n- A text criterion may begin with a comparison operator — `\">5\"`, `\"<>x\"`, `\">=\"&A1` — and the\n  operator is parsed out of the string.\n- Wildcards `?` and `*` apply to text criteria, with `~` as the escape.\n- Microsoft documents that a criteria argument referring to an empty cell is **treated as 0**.\n  That is a sharp edge: `MAXIFS(B:B, A:A, C1)` with `C1` blank does not mean \"no filter\", it\n  means \"equal to zero\".\n\n\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **Non-numeric cells at selected positions** are not part of a numeric maximum. Whether they\n  are skipped or cause an error is not stated on Microsoft's page for this function, and the\n  Handbook has not checked.\n- **Shape mismatch** → `#VALUE!`, documented.\n- **Whole-column ranges** (`A:A` against `B:B`) match in shape and are the common idiom;\n  performance is an engine matter the Handbook does not assert on.\n- **Criteria referring to an empty cell** are treated as `0`, documented — see above.\n\n\n\n### Errors\n\nMicrosoft's page documents exactly one error condition. It does not document a `#NUM!`, a\n`#N/A`, or an error for the no-match case — the no-match answer is `0`.\n\n\n",
    "sources": "- Handbook [MAX](FUNC.MAX.md) — the unconditional reduction, the empty-set convention and its\n  associativity trap.\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md) — the family-policy\n  treatment of comparison and scanning.\n- Handbook projections `data/functions/FUNC.MAXIFS.json` (arity 3–255, **no `xlcall` entry**,\n  `RefsVisibleInAdapter`, `ReductionFold`, `SequentialLeftFold`) and\n  `data/presence/FUNC.MAXIFS.json` (module `criteria_family.rs`, shared with `AVERAGEIF`,\n  `AVERAGEIFS`, `COUNTIF`, `COUNTIFS`, `MINIFS`, `SUMIF`, `SUMIFS`).\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`MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)` returns the\nlargest value among the cells of `max_range` whose correspondingly-positioned cells in every\ncriteria range satisfy the matching criterion.\n\nWritten out, with `i` ranging over positions in the common shape:\n\n    S = { i : P₁(criteria_range1[i]) ∧ P₂(criteria_range2[i]) ∧ … ∧ P_k(criteria_range_k[i]) }\n    MAXIFS = max { max_range[i] : i ∈ S, max_range[i] is numeric }\n\nTwo structural facts:\n\n1. **The conditions are combined with AND, positionally.** Criteria pairs intersect; there is\n   no OR form and no way to write one inside a single call. Position, not value, is what links\n   a criteria cell to a `max_range` cell — which is why the shapes must match.\n2. **`MAXIFS` is a selection stage followed by a reduction.** Everything about the selection is\n   shared with the rest of the criteria family; everything about the reduction is shared with\n   [MAX](FUNC.MAX.md). The two halves are worth thinking about separately, because they carry\n   different risks — the selection carries a comparison-tolerance question, the reduction\n   carries the empty-set question.\n\nMicrosoft documents the size requirement directly: \"The size and shape of the max_range and\ncriteria_rangeN arguments must be the same, otherwise these functions return the #VALUE!\nerror.\"\n\n**Domain and result.** `max_range` may hold anything; only its numeric cells participate in the\nmaximum. The result is a real number. When `S` is empty — or when no cell of `max_range` at a\nselected position is numeric — Microsoft documents that the function returns `0`.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Required |\n|---|---|---|\n| `max_range` | \"The actual range of cells in which the maximum will be determined.\" | Yes |\n| `criteria_range1` | \"Is the set of cells to evaluate with the criteria.\" | Yes |\n| `criteria1` | \"Is the criteria in the form of a number, expression, or text that defines which cells will be evaluated as maximum.\" | Yes |\n| `criteria_range2, criteria2, …` | \"Additional ranges and their associated criteria. You can enter up to 126 range/criteria pairs.\" | No |\n\n**Ranges must match in shape, not merely in count.** A `3×1` `max_range` against a `1×3`\ncriteria range is a shape mismatch even though both hold three cells.\n\n"
  },
  "signature": {
    "display": "MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "max_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": "Largest value among the cells that meet every condition",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the maximum value among cells specified by a given set of conditions or criteria",
        "microsoft_url": "https://support.microsoft.com/en-us/office/maxifs-function-dfd611e6-da2c-488a-919b-9b6376b28883"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "MAXIFS"
        },
        {
          "locale": "bg-BG",
          "name": "MAXIFS"
        },
        {
          "locale": "cs-CZ",
          "name": "MAXIFS"
        },
        {
          "locale": "da-DK",
          "name": "MAKSHVISER"
        },
        {
          "locale": "de-DE",
          "name": "MAXIFS"
        },
        {
          "locale": "el-GR",
          "name": "MAXIFS"
        },
        {
          "locale": "en-AU",
          "name": "MAXIFS"
        },
        {
          "locale": "en-GB",
          "name": "MAXIFS"
        },
        {
          "locale": "en-US",
          "name": "MAXIFS"
        },
        {
          "locale": "es-ES",
          "name": "MAX.SI.CONJUNTO"
        },
        {
          "locale": "et-EE",
          "name": "MAXIFS"
        },
        {
          "locale": "fi-FI",
          "name": "MAKS.JOS.JOUKKO"
        },
        {
          "locale": "fr-FR",
          "name": "MAX.SI.ENS*"
        },
        {
          "locale": "he-IL",
          "name": "MAXIFS"
        },
        {
          "locale": "hr-HR",
          "name": "MAXIFS"
        },
        {
          "locale": "hu-HU",
          "name": "MAXHA"
        },
        {
          "locale": "id-ID",
          "name": "MAXIFS"
        },
        {
          "locale": "it-IT",
          "name": "MAXIFS"
        },
        {
          "locale": "ja-JP",
          "name": "MAXIFS"
        },
        {
          "locale": "ko-KR",
          "name": "MAXIFS"
        },
        {
          "locale": "lt-LT",
          "name": "MAXIFS"
        },
        {
          "locale": "lv-LV",
          "name": "MAXIFS"
        },
        {
          "locale": "nb-NO",
          "name": "MAXIFS"
        },
        {
          "locale": "nl-NL",
          "name": "MAX.ALS.VOORWAARDEN"
        },
        {
          "locale": "pl-PL",
          "name": "MAKS.WARUNKÓW"
        },
        {
          "locale": "pt-BR",
          "name": "MAXIFS"
        },
        {
          "locale": "pt-PT",
          "name": "MÁXIMO.SE.S"
        },
        {
          "locale": "ro-RO",
          "name": "MAXIFS"
        },
        {
          "locale": "ru-RU",
          "name": "МАКСЕСЛИ"
        },
        {
          "locale": "sk-SK",
          "name": "MAXIFS"
        },
        {
          "locale": "sl-SI",
          "name": "MAXIFS"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "MAXIFS"
        },
        {
          "locale": "sv-SE",
          "name": "MAXIFS"
        },
        {
          "locale": "th-TH",
          "name": "MAXIFS"
        },
        {
          "locale": "tr-TR",
          "name": "ÇOKEĞERMAK"
        },
        {
          "locale": "uk-UA",
          "name": "MAXIFS"
        },
        {
          "locale": "vi-VN",
          "name": "MAXIFS"
        },
        {
          "locale": "zh-CN",
          "name": "MAXIFS"
        },
        {
          "locale": "zh-HK",
          "name": "MAXIFS"
        },
        {
          "locale": "zh-TW",
          "name": "MAXIFS"
        }
      ],
      "signature": {
        "display": "MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2], [criteria2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "max_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": "MAXIFS",
      "version_marker": null,
      "xlcall": null
    },
    "microsoft": "https://support.microsoft.com/en-us/office/maxifs-function-dfd611e6-da2c-488a-919b-9b6376b28883"
  },
  "try_it": {
    "formula": "=MAXIFS(C2:C4,B2:B4,\">1\")",
    "inputs": {
      "B2": 1,
      "B3": 2,
      "B4": 3,
      "C2": 10,
      "C3": 20,
      "C4": 30
    }
  },
  "url": "https://handbook.dnacalc.com/functions/MAXIFS.html",
  "variants": [],
  "versions": []
}