{
  "category": "Statistical functions",
  "display_name": "MAX",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.MAX",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 1211,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 1211,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 1,211 in the answer bank and 25 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 1,236 recorded answers",
    "workbook_corpus": {
      "cells": 25,
      "matched": 25
    }
  },
  "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/aggregate.rs#L114-L114",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/aggregate.rs#L261-L267"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/aggregate::aggregate",
        "catalogue/aggregate::extreme",
        "catalogue/aggregate::holds_held_arrays",
        "catalogue/aggregate::read_held_references",
        "catalogue/aggregate::number_of",
        "catalogue/aggregate::each_value",
        "catalogue/aggregate::read_values",
        "catalogue/aggregate::reader",
        "catalogue/aggregate::read_reference",
        "catalogue/comparison::overflow_numbers",
        "catalogue/comparison::numbers",
        "catalogue/comparison::in_band",
        "catalogue/comparison::Rounded::up",
        "catalogue/comparison::Roundings::of",
        "catalogue/comparison::Roundings::disjoint",
        "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"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/aggregate.rs#L114-L114",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 1,236 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.MAX.json",
  "name": "MAX",
  "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- **[MIN](FUNC.MIN.md)** — the exact mirror, same argument shape, same coercion table, same\n  documented zero for the no-numbers case. Any behavioural difference between `MAX` and `MIN`\n  beyond the comparator is a defect in one of them.\n- **[MAXA](FUNC.MAXA.md)** — the variant that counts text and logicals inside references,\n  named by Microsoft's own `MAX` page as the remedy. The `A` suffix family (`MAXA`, `MINA`,\n  `AVERAGEA`, `COUNTA`, `STDEVA`, `VARA`) shares that intent and does not share one uniform\n  rule; each page states its own.\n- **[MAXIFS](FUNC.MAXIFS.md)** — the conditional form, which selects the population by criteria\n  before taking the maximum. Note that `MAXIFS` returns `0` when no cell meets the criteria,\n  which is the same convention the `MAX` documentation states for the empty case.\n- **[LARGE](FUNC.LARGE.md)** — the general order-statistic selector; `LARGE(array, 1)` is the\n  maximum over the same admitted set, but `LARGE` takes exactly one array and errors on an\n  empty one instead of returning zero. The pair `MAX`/`LARGE` is the cleanest illustration of\n  the empty-set convention differing between two functions that compute the same thing.\n- **[DMAX](FUNC.DMAX.md)** — the database-family maximum, with criteria-range selection.\n- **[SUBTOTAL](FUNC.SUBTOTAL.md)** (function numbers 4 and 104) and\n  **[AGGREGATE](FUNC.AGGREGATE.md)** (function number 4) — the filter-aware and\n  error-skipping maxima. `AGGREGATE` is the only route to a maximum that ignores error values,\n  which `MAX` cannot do.\n- **Confused with:** `MAX` and `LARGE` on ranges containing text (the same scan policy governs\n  both, so they should agree — a disagreement is diagnostic); and with the idea that `MAX` over\n  an empty range is an error, which the documentation contradicts.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`MAX` has no arithmetic and therefore no rounding error. The engineering questions are three,\nand each of them is about definition rather than precision.\n\n**1. The comparison predicate.** A maximum needs a total order. IEEE-754 `>` is a total order\non the doubles Excel can hold, with the single exception that `+0` and `−0` compare equal —\nExcel has no NaN in its value universe, so the usual NaN-poisoning problem does not arise at\nthis level. Whether Excel's `MAX` uses raw `>` or the tolerant, truncation-style\n15-significant-digit comparison it applies in some other families is a genuine open question;\nfor `MAX` a tolerant comparator would only affect which of two near-equal representations is\nreturned, so the consequence is smaller than it is for lookups, but it is observable.\n\n**3. The empty-set identity.** Mathematically `max ∅ = −∞`, which Excel cannot represent, so\nthe specification substitutes `0`. That substitution is not innocuous: it makes `MAX`\nnon-associative across the empty case in a way that matters for incremental computation. If a\nrange is empty, `MAX` returns a value inside the data's range rather than below it, so\n`MAX(MAX(A), MAX(B))` is not `MAX(A ∪ B)` when one of `A` or `B` is empty and the other is\nentirely negative. A workbook that computes column maxima and then takes the maximum of those\nwill report `0` for a set of all-negative data with one empty column. That is a real, silent\ncorrectness trap and it follows directly from the documented rule.\n\nFor an implementer: initialise the accumulator with a sentinel *and a found flag*, never with\n`0` or with `f64::NEG_INFINITY` alone — the first is wrong for all-negative data and the second\nproduces `−∞`, which is outside Excel's value universe. Track \"have I seen a number\" separately\nfrom \"what is the best so far\", and apply the documented zero only at the end.\n\n\n",
    "quirks": "\n### The two coercion policies\n\n\nThis is the section that earns the page, and it is quoted rather than paraphrased because the\ndistinction is exact. Microsoft's `MAX` page states:\n\n- \"Arguments can either be numbers or names, arrays, or references that contain numbers.\"\n- \"Logical values and text representations of numbers that you type directly into the list of\n  arguments are counted.\"\n- \"If an argument is an array or reference, only numbers in that array or reference are used.\n  Empty cells, logical values, or text in the array or reference are ignored.\"\n- \"If the arguments contain no numbers, MAX returns 0 (zero).\"\n- \"Arguments that are error values or text that cannot be translated into numbers cause\n  errors.\"\n\nRead as a table:\n\n| Value | Typed **directly** into the argument list | Reached inside an **array or reference** |\n|---|---|---|\n| Number | counted | counted |\n| `TRUE` / `FALSE` | counted (as 1 / 0) | **ignored** |\n| Text that reads as a number | counted | **ignored** |\n| Text that does not read as a number | **error** | ignored |\n| Empty cell | — | ignored |\n| Error value | error | error |\n\nSo `MAX(TRUE, 0)` is 1 while `MAX(A1:A2)` with `TRUE` in `A1` and `0` in `A2` is 0. Same\nvalues, same function, different boundary, different rule. This is the flagship asymmetry of\n[Coercion and lifting](../model/02-coercion-and-lifting.md), and `MAX` is one of the cleanest\nplaces to see it, because both branches are documented on the same page in consecutive\nsentences.\n\nThe practical consequence is that `MAX` over a column cannot be made to see logicals or\nnumeric text. Microsoft's own page names the remedy: \"If you want to include logical values\nand text representations of numbers in a reference as part of the calculation, use the MAXA\nfunction.\" See [MAXA](FUNC.MAXA.md), and read its own coercion rules before switching, because\nthey are not simply \"the same but including text\".\n\n\n\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **No numbers among the arguments.** Microsoft documents: \"If the arguments contain no\n  numbers, MAX returns 0 (zero).\" So `MAX` over a wholly blank range is documented to be `0`,\n  not an error and not the empty value.\n\n- **A single value.** `MAX(x)` is `x`, including for the largest finite double and the\n  smallest subnormal, which is a useful check that no normalisation is applied on the way out.\n- **`+0` and `−0`.** IEEE comparison calls these equal, so which one is returned is a\n  tie-breaking decision the specification does not make. `MAX(0, −0)` may legitimately return\n  either representation, and the two are distinguishable through the sign bit and through\n  `1/x`. Unverified.\n- **Arrays** are consumed by scanning, not lifted elementwise; `MAX` is not a lift kernel.\n- **Dates and times** are numbers wearing formats, so `MAX` over a date column returns the\n  latest date — correctly, and with the format usually carried through by the cell rather than\n  by the function.\n\n\n\n### Errors\n\nThere is no documented `#NUM!` or `#N/A` condition. Note the absence of an \"empty input\" error\nin the documentation — the documented answer for that case is `0`, as discussed above.\n\n\n",
    "sources": "- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md) — the direct-argument\n  versus range-scan asymmetry, of which this function is the canonical instance.\n- Handbook [The value universe](../model/01-value-universe.md) — value kinds, the absence of\n  infinities and NaN from the published gamut, and the Empty/Missing distinction.\n- Handbook projections `data/functions/FUNC.MAX.json` (arity 1–255, `xlfMax` code 7,\n  `AggregateDirectAndRangeDualPolicy`, `ReductionFold`, `SequentialLeftFold`,\n  `CanonicalExcelLegacy` error algebra) and `data/presence/FUNC.MAX.json` (module `max_fn.rs`,\n  unshared, no defect stream named).\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20430 | Windows, 64-bit, CPU not recorded | 1,211 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.MAX.json).",
    "what-it-does": "\n`MAX(number1, [number2], …)` returns the largest of the numeric values it admits.\n\nAs mathematics this is the top order statistic, `x₍ₙ₎ = max{x₁ … xₙ}` — the supremum of a\nfinite set, which is attained and is therefore one of the inputs. `MAX` is a **selector**: its\nresult is bit-identical to one of the values it was given, it performs no arithmetic, and it\nintroduces no rounding error of its own.\n\nBecause there is no arithmetic, everything genuinely interesting about `MAX` lives in one\nquestion: **which values count?** That question has two different answers depending on how the\nvalue reached the function, and Microsoft documents both.\n\n`max` is associative, commutative and idempotent, with identity `−∞`; it is a monoid fold. The\nidentity is where the specification has to make a choice, because Excel has no `−∞` in its\nvalue universe. Microsoft's choice is documented and stated below.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Notes |\n|---|---|---|\n| `number1` | The first value | Required |\n| `number2, …` | Further values | Optional |\n\nArgument boundaries carry no meaning: `MAX(A1:A10)`, `MAX(A1:A5, A6:A10)` and\n`MAX(A1, A2, …, A10)` all reduce over one pooled set. There is no per-argument grouping and no\nshort-circuiting.\n\n\n"
  },
  "signature": {
    "display": "MAX(number1, [number2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "number1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "number2",
        "optional": true,
        "repeats": true
      }
    ],
    "trailing_repeats": true
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 255,
        "min": 1
      },
      "category": "Statistical functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "AggregateDirectAndRangeDualPolicy",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "ReductionFold",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "NumsToNum",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Largest of the numbers",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the maximum value in a list of arguments",
        "microsoft_url": "https://support.microsoft.com/en-us/office/max-function-e0012414-9ac8-4b34-9a47-73e662c08098"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "MAX"
        },
        {
          "locale": "bg-BG",
          "name": "MAX"
        },
        {
          "locale": "cs-CZ",
          "name": "MAX"
        },
        {
          "locale": "da-DK",
          "name": "MAKS"
        },
        {
          "locale": "de-DE",
          "name": "MAX"
        },
        {
          "locale": "el-GR",
          "name": "MAX"
        },
        {
          "locale": "en-AU",
          "name": "MAX"
        },
        {
          "locale": "en-GB",
          "name": "MAX"
        },
        {
          "locale": "en-US",
          "name": "MAX"
        },
        {
          "locale": "es-ES",
          "name": "MAX"
        },
        {
          "locale": "et-EE",
          "name": "MAX"
        },
        {
          "locale": "fi-FI",
          "name": "MAKS"
        },
        {
          "locale": "fr-FR",
          "name": "MAX"
        },
        {
          "locale": "he-IL",
          "name": "MAX"
        },
        {
          "locale": "hr-HR",
          "name": "MAX"
        },
        {
          "locale": "hu-HU",
          "name": "MAX"
        },
        {
          "locale": "id-ID",
          "name": "MAX"
        },
        {
          "locale": "it-IT",
          "name": "MAX"
        },
        {
          "locale": "ja-JP",
          "name": "MAX"
        },
        {
          "locale": "ko-KR",
          "name": "MAX"
        },
        {
          "locale": "lt-LT",
          "name": "MAX"
        },
        {
          "locale": "lv-LV",
          "name": "MAX"
        },
        {
          "locale": "nb-NO",
          "name": "MAKS"
        },
        {
          "locale": "nl-NL",
          "name": "MAX"
        },
        {
          "locale": "pl-PL",
          "name": "MAX"
        },
        {
          "locale": "pt-BR",
          "name": "MÁX"
        },
        {
          "locale": "pt-PT",
          "name": "MAX"
        },
        {
          "locale": "ro-RO",
          "name": "MAX"
        },
        {
          "locale": "ru-RU",
          "name": "МАКС"
        },
        {
          "locale": "sk-SK",
          "name": "MAX"
        },
        {
          "locale": "sl-SI",
          "name": "MAX"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "MAX"
        },
        {
          "locale": "sv-SE",
          "name": "MAX"
        },
        {
          "locale": "th-TH",
          "name": "MAX"
        },
        {
          "locale": "tr-TR",
          "name": "MAK"
        },
        {
          "locale": "uk-UA",
          "name": "MAX"
        },
        {
          "locale": "vi-VN",
          "name": "MAX"
        },
        {
          "locale": "zh-CN",
          "name": "MAX"
        },
        {
          "locale": "zh-HK",
          "name": "MAX"
        },
        {
          "locale": "zh-TW",
          "name": "MAX"
        }
      ],
      "signature": {
        "display": "MAX(number1, [number2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "number1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "number2",
            "optional": true,
            "repeats": true
          }
        ],
        "trailing_repeats": true
      },
      "surface_name": "MAX",
      "version_marker": null,
      "xlcall": {
        "code": "7",
        "symbol": "xlfMax"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/max-function-e0012414-9ac8-4b34-9a47-73e662c08098"
  },
  "try_it": {
    "formula": "=MAX(1,5,3)"
  },
  "url": "https://handbook.dnacalc.com/functions/MAX.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "1,211 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.MAX.json"
      ]
    }
  ]
}