{
  "category": "Lookup and reference functions",
  "display_name": "OFFSET",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.OFFSET",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 7 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 7 recorded answers",
    "workbook_corpus": {
      "cells": 8,
      "matched": 7,
      "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/offset.rs#L38-L52",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/offset.rs#L78-L95",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/offset.rs#L97-L124",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/offset.rs#L126-L131",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/offset.rs#L133-L144"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/offset::span"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/offset.rs#L38-L52",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 7 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.OFFSET.json",
  "name": "OFFSET",
  "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- **`INDEX`** is the closest sibling and the recommended replacement for most dynamic-range\n  work: it also returns a reference, but from an explicit range and without volatility.\n- **`INDIRECT`** is the other reference-producing function, and is also volatile; it builds a\n  reference from *text*, which is strictly more dangerous and strictly less analyzable.\n- **`ROW`, `ROWS`, `COLUMN`, `COLUMNS`, `CELL`, `ADDRESS`** are the rest of the\n  reference-inspection family; `OFFSET` is the reference-*producing* member.\n- **`TRIMRANGE`** and the trim-reference operators occupy some of the ground `OFFSET` was used\n  for — trimming a whole-column reference down to its populated extent — without volatility.\n- Readers confuse `OFFSET` with `INDEX`'s reference form (which selects within a range rather\n  than displacing from it) and with `INDIRECT`.\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n- The first argument must arrive reference-bearing. If argument preparation dereferences it,\n  the function cannot be written: there is no address left to displace.\n- The result must be a reference, not the values at that address. A tempting shortcut is to\n  materialize the area and return an array; it produces the right numbers in `SUM(OFFSET(...))`\n  and the wrong answer everywhere the reference identity is observed — `CELL(\"address\",\n  OFFSET(...))` is the cheap test.\n- Default `height` and `width` come from the base reference's extent, which means the\n  function needs the base's *shape*, not just its top-left cell.\n- Volatility must be declared, not inferred. An engine that constant-folds `OFFSET` because\n  all its arguments are literals will produce a stale reference after a row insertion.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nThe result kind is `ReferenceLike` — an `A1` shape when the computed extent is a single cell,\nan `Area` shape otherwise. This matters because a reference can be consumed in ways a value\ncannot: it can be handed to `SUM`, to `ROWS`, to `CELL(\"address\", …)`, or to the `:` range\noperator, and it can be resized again.\n\n- **Published into a cell**, an area-shaped result is materialized: on a modern Excel it\n  spills; on the legacy grid model an unrequested area produced a `#VALUE!` unless entered as\n  an array formula. Which of those a reader sees is a property of the host and the workbook's\n  calculation surface, not of `OFFSET`.\n- **Displacement off the grid** is an error, not a clamp. Moving before row 1 or column A, or\n  past the last row or column, yields `#REF!`.\n- **A base reference on another sheet** displaces within that sheet; `OFFSET` carries the\n  sheet identity of its base.\n- Reference resolution and the values-versus-references distinction are described once in\n  [the call pipeline](../model/03-call-pipeline.md), stage 1; `OFFSET` is one of the named\n  `RefsVisibleInAdapter` functions there.\n\n\n\n### Volatility\n\n\n`OFFSET` is **volatile**. It is recomputed on every recalculation of the workbook, whether or\nnot any cell it depends on has changed, and everything downstream of it is recomputed too.\n\nThis is not an implementation choice that could be optimized away. `OFFSET`'s arguments name a\n*displacement*, so the engine cannot know which cells the result will designate until it has\nevaluated the function — the dependency graph cannot be built statically from the formula\ntext. Volatility is the price of that late binding.\n\nThe practical consequence is that `OFFSET` used at scale is a recalculation cost multiplier: a\nfew thousand volatile cells, each with a dependent subtree, is a workbook that pauses on every\nedit. The usual modern replacements are:\n\n- **structured table references** (`Table1[Amount]`), which grow with the table and are not\n  volatile;\n- **`INDEX`**, which returns a reference from an explicit range and is not volatile — the\n  `A1:INDEX(A:A, n)` idiom builds a dynamic range without volatility;\n- **spill anchors** (`B1#`), which reference a dynamic array's current extent directly;\n- **`TRIMRANGE`** and the trim-reference operators, for the specific case of \"the used part of\n  this column\".\n\n\n### Errors\n\n\nDocumented by Microsoft:\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | `reference` is not a cell or a contiguous range (for example, a multi-area union) |\n| `#REF!` | `rows` and `cols` displace the reference over the edge of the worksheet |\n\n",
    "sources": "- Microsoft, *OFFSET function* —\n  <https://support.microsoft.com/en-us/office/offset-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66>\n  (syntax, argument meanings, the `height`/`width` defaults, the `#VALUE!` and `#REF!`\n  conditions, the statement that `OFFSET` returns a reference without moving cells, and\n  volatility). Retrieved for this page.\n- Handbook `content/model/01-value-universe.md` (reference shapes and the reference domain)\n  and `content/model/03-call-pipeline.md` (reference-aware argument preparation).\n- Handbook `data/functions/FUNC.OFFSET.json` (signature, arity, volatility and dependency\n  axes).\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`OFFSET` is one of the few worksheet functions whose **result is a reference**, not a value.\nIt performs arithmetic in the address space of the grid.\n\nGiven a base reference `B` whose top-left cell is at row `r₀` and column `c₀`, and whose\nextent is `h₀ × w₀`, together with displacements `Δr` and `Δc` and optional dimensions `h` and\n`w`, `OFFSET` returns the rectangular area\n\n- whose top-left cell is at row `r₀ + Δr` and column `c₀ + Δc`,\n- with height `h` (default `h₀`) and width `w` (default `w₀`).\n\nNote precisely what the defaults mean: **the returned area inherits the base reference's\nshape, not a single cell.** `OFFSET(A1:C3, 1, 1)` is `B2:D4`, a 3×3 area — not `B2`. This is\nthe detail that most surprises readers who think of `OFFSET` as \"the cell `n` down from here\".\n\nMicrosoft states the other half explicitly: `OFFSET` does not move any cells or change the\nselection; it computes an address. What happens to that address afterwards is the caller's\nbusiness — a consuming function resolves it, an aggregate scans it, a cell publishes its\ncontents (or spills them).\n\nThe value of `OFFSET` is that its displacement and its size are *computed*. `OFFSET(A1, 0, 0,\nCOUNTA(A:A), 1)` is a range whose length tracks the data — the classic dynamic-range idiom,\nand the reason `OFFSET` outlived several attempts to replace it.\n\n\n\n### Arguments\n\n\n**`reference`** — the base. Must be a single cell or a contiguous range; a multi-area union is\nrejected. Its size supplies the defaults for `height` and `width`.\n\n**`rows`** — vertical displacement, positive downward, negative upward.\n\n**`cols`** — horizontal displacement, positive rightward, negative leftward.\n\n**`height`** — optional row count of the result, defaulting to the base reference's height.\n\n**`width`** — optional column count of the result, defaulting to the base reference's width.\n\n"
  },
  "signature": {
    "display": "OFFSET(reference, rows, cols, [height], [width])",
    "parameters": [
      {
        "description": null,
        "name": "reference",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "rows",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "cols",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "height",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "width",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 5,
        "min": 3
      },
      "category": "Lookup and reference functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "CallerContext",
        "host_interaction_class": "WorkbookState",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "CallerContext",
        "thread_safety_class": "HostSerialized",
        "volatility_class": "VolatileContextual"
      },
      "descriptions": {
        "long": null,
        "short": "A reference shifted by rows and columns from a start, optionally resized",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns a reference offset from a given reference",
        "microsoft_url": "https://support.microsoft.com/en-us/office/offset-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "OFFSET"
        },
        {
          "locale": "bg-BG",
          "name": "OFFSET"
        },
        {
          "locale": "cs-CZ",
          "name": "POSUN"
        },
        {
          "locale": "da-DK",
          "name": "FORSKYDNING"
        },
        {
          "locale": "de-DE",
          "name": "BEREICH.VERSCHIEBEN"
        },
        {
          "locale": "el-GR",
          "name": "OFFSET"
        },
        {
          "locale": "en-AU",
          "name": "OFFSET"
        },
        {
          "locale": "en-GB",
          "name": "OFFSET"
        },
        {
          "locale": "en-US",
          "name": "OFFSET"
        },
        {
          "locale": "es-ES",
          "name": "DESREF"
        },
        {
          "locale": "et-EE",
          "name": "OFFSET"
        },
        {
          "locale": "fi-FI",
          "name": "SIIRTYMÄ"
        },
        {
          "locale": "fr-FR",
          "name": "DECALER"
        },
        {
          "locale": "he-IL",
          "name": "OFFSET"
        },
        {
          "locale": "hr-HR",
          "name": "OFFSET"
        },
        {
          "locale": "hu-HU",
          "name": "ELTOLÁS"
        },
        {
          "locale": "id-ID",
          "name": "OFFSET"
        },
        {
          "locale": "it-IT",
          "name": "SCARTO"
        },
        {
          "locale": "ja-JP",
          "name": "OFFSET"
        },
        {
          "locale": "ko-KR",
          "name": "OFFSET"
        },
        {
          "locale": "lt-LT",
          "name": "OFFSET"
        },
        {
          "locale": "lv-LV",
          "name": "OFFSET"
        },
        {
          "locale": "nb-NO",
          "name": "FORSKYVNING"
        },
        {
          "locale": "nl-NL",
          "name": "VERSCHUIVING"
        },
        {
          "locale": "pl-PL",
          "name": "PRZESUNIĘCIE"
        },
        {
          "locale": "pt-BR",
          "name": "DESLOC"
        },
        {
          "locale": "pt-PT",
          "name": "DESLOCAMENTO"
        },
        {
          "locale": "ro-RO",
          "name": "OFFSET"
        },
        {
          "locale": "ru-RU",
          "name": "СМЕЩ"
        },
        {
          "locale": "sk-SK",
          "name": "OFFSET"
        },
        {
          "locale": "sl-SI",
          "name": "OFFSET"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "OFFSET"
        },
        {
          "locale": "sv-SE",
          "name": "FÖRSKJUTNING"
        },
        {
          "locale": "th-TH",
          "name": "OFFSET"
        },
        {
          "locale": "tr-TR",
          "name": "KAYDIR"
        },
        {
          "locale": "uk-UA",
          "name": "OFFSET"
        },
        {
          "locale": "vi-VN",
          "name": "OFFSET"
        },
        {
          "locale": "zh-CN",
          "name": "OFFSET"
        },
        {
          "locale": "zh-HK",
          "name": "OFFSET"
        },
        {
          "locale": "zh-TW",
          "name": "OFFSET"
        }
      ],
      "signature": {
        "display": "OFFSET(reference, rows, cols, [height], [width])",
        "parameters": [
          {
            "description": null,
            "name": "reference",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "rows",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "cols",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "height",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "width",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "OFFSET",
      "version_marker": null,
      "xlcall": {
        "code": "78",
        "symbol": "xlfOffset"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/offset-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66"
  },
  "try_it": {
    "formula": "=OFFSET(B2,1,0)",
    "inputs": {
      "B2": 1,
      "B3": 2
    }
  },
  "url": "https://handbook.dnacalc.com/functions/OFFSET.html",
  "variants": [],
  "versions": []
}