{
  "category": "Our 10 featured functions",
  "display_name": "LET",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.LET",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 58 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": false,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 58 recorded answers",
    "workbook_corpus": {
      "cells": 60,
      "matched": 58,
      "pending": 2
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-fml/src/eval/compile.rs#L1364-L1415"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "eval/compile::declared_name",
        "eval/compile::parameter_key",
        "eval/compile::without_prefix",
        "eval/compile::only_token",
        "eval/compile::text",
        "syntax/token::Token::text"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-fml/src/eval/compile.rs#L1364-L1415",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 58 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.LET.json",
  "name": "LET",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\nUse [LAMBDA](FUNC.LAMBDA.md) to define a function with arguments for later calls. Workbook-defined\nnames provide a wider scope. Helper cells expose intermediate results in the worksheet when\nthat makes a model easier to inspect.\n\n\n",
    "how-to-implement": "\nParse LET as a binding form, preserving the name tokens and the unevaluated expressions. Build\na lexical scope and add bindings in order. A binding's expression resolves names against the\nscope that exists before that binding, while subsequent expressions see it. Evaluate the final\nexpression in the resulting scope and return its value unchanged.\n\nKeep local bindings separate from workbook-defined names and from cell references. A cached\nbinding must preserve value kind, array shape, reference identity and callable environment.\nMeasure evaluation of unused and repeated volatile bindings before choosing between eager\nbinding and evaluation on demand. LET's advertised benefit is avoiding repeated calculation;\nthat does not settle every unused-binding case.\n\n\n",
    "quirks": "\nThe last argument is an expression to return. Ending with a name/value pair leaves no final\ncalculation. Names must satisfy Excel's naming rules; names that conflict with reference syntax\ncan be refused. A short name such as `c` can conflict with R1C1 notation.\n\nAn inner LET can shadow an outer name. A lambda created in a LET may use its enclosing names;\nthose names must remain meaningful when the callable is invoked. Worksheet references and\nvolatile expressions make the timing of evaluation observable, so a mathematical substitution\nis not by itself a compatibility rule.\n\n\n",
    "sources": "\n- [Microsoft: LET function](https://support.microsoft.com/en-us/excel/functions/let-function).\n- [The formula call pipeline](../model/03-call-pipeline.md).\n\n",
    "try-it": "\nTry `=LET(x,3,x*x)`, then `=LET(x,3,y,x+2,x*y)`. The second example uses an earlier binding to\ncalculate the next one. For a reusable calculation, put LET inside a LAMBDA.\n\n\n",
    "version-differences": "\nMicrosoft lists LET for Microsoft 365, Excel 2021 and Excel 2024 on Windows and Mac. There is no\nbuild-by-build comparison of evaluation timing recorded here.\n\n\n",
    "what-it-does": "\n`LET(name1, value1, [name2, value2], …, calculation)` names intermediate values inside one\nformula, then returns the final calculation. Each later binding and the final calculation can\nuse earlier names. Microsoft allows up to 126 name/value pairs.\n\n`=LET(price,100,tax,0.15,price*(1+tax))` calculates 115. The names belong to that expression;\nthey do not create workbook names or fill cells.\n\n\n"
  },
  "signature": {
    "display": "LET(name1, value1, [name2, value2], …, calculation)",
    "max_arguments": 253,
    "min_arguments": 3,
    "parameters": [
      {
        "description": "First local name.",
        "name": "name1",
        "optional": false,
        "repeats": false
      },
      {
        "description": "Expression bound to name1.",
        "name": "value1",
        "optional": false,
        "repeats": false
      },
      {
        "description": "Final expression; optional name/value pairs may precede it.",
        "name": "calculation",
        "optional": false,
        "repeats": false
      }
    ],
    "repeating_group": {
      "before": "calculation",
      "max_groups": 126,
      "parameters": [
        "name",
        "value"
      ]
    },
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "formula_layer",
        "reason": null
      },
      "arity": {
        "max": 253,
        "min": 3
      },
      "category": "Our 10 featured functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "A calculation that names intermediate results and uses them",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Use this function to assign names to calculation results.",
        "microsoft_url": "https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "LET"
        },
        {
          "locale": "bg-BG",
          "name": "LET"
        },
        {
          "locale": "cs-CZ",
          "name": "LET"
        },
        {
          "locale": "da-DK",
          "name": "LET"
        },
        {
          "locale": "de-DE",
          "name": "LET"
        },
        {
          "locale": "el-GR",
          "name": "LET"
        },
        {
          "locale": "en-AU",
          "name": "LET"
        },
        {
          "locale": "en-GB",
          "name": "LET"
        },
        {
          "locale": "en-US",
          "name": "LET"
        },
        {
          "locale": "es-ES",
          "name": "LET"
        },
        {
          "locale": "et-EE",
          "name": "LET"
        },
        {
          "locale": "fi-FI",
          "name": "LET"
        },
        {
          "locale": "fr-FR",
          "name": "LET*"
        },
        {
          "locale": "he-IL",
          "name": "LET"
        },
        {
          "locale": "hr-HR",
          "name": "LET"
        },
        {
          "locale": "hu-HU",
          "name": "LET"
        },
        {
          "locale": "id-ID",
          "name": "LET"
        },
        {
          "locale": "it-IT",
          "name": "LET"
        },
        {
          "locale": "ja-JP",
          "name": "LET"
        },
        {
          "locale": "ko-KR",
          "name": "LET"
        },
        {
          "locale": "lt-LT",
          "name": "LET"
        },
        {
          "locale": "lv-LV",
          "name": "LET"
        },
        {
          "locale": "nb-NO",
          "name": "LET"
        },
        {
          "locale": "nl-NL",
          "name": "LET"
        },
        {
          "locale": "pl-PL",
          "name": "LET"
        },
        {
          "locale": "pt-BR",
          "name": "LET"
        },
        {
          "locale": "pt-PT",
          "name": "LET"
        },
        {
          "locale": "ro-RO",
          "name": "LET"
        },
        {
          "locale": "ru-RU",
          "name": "LET"
        },
        {
          "locale": "sk-SK",
          "name": "LET"
        },
        {
          "locale": "sl-SI",
          "name": "LET"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "LET"
        },
        {
          "locale": "sv-SE",
          "name": "LET"
        },
        {
          "locale": "th-TH",
          "name": "LET"
        },
        {
          "locale": "tr-TR",
          "name": "İZİN"
        },
        {
          "locale": "uk-UA",
          "name": "LET"
        },
        {
          "locale": "vi-VN",
          "name": "LET"
        },
        {
          "locale": "zh-CN",
          "name": "LET"
        },
        {
          "locale": "zh-HK",
          "name": "LET"
        },
        {
          "locale": "zh-TW",
          "name": "LET"
        }
      ],
      "signature": {
        "display": "LET(name1, name_value1, calculation_or_name2, [name_value2], [calculation_or_name3], ...)",
        "parameters": [
          {
            "description": null,
            "name": "name1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "name_value1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "calculation_or_name2",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "name_value2",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "calculation_or_name3",
            "optional": true,
            "repeats": true
          }
        ],
        "trailing_repeats": true
      },
      "surface_name": "LET",
      "version_marker": null,
      "xlcall": null
    },
    "microsoft": "https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999"
  },
  "try_it": {
    "formula": "=LET(x,3,x*x)"
  },
  "url": "https://handbook.dnacalc.com/functions/LET.html",
  "variants": [],
  "versions": []
}