Formualizer Docs

LET

Binds local names to values and evaluates a final expression with those bindings.

LET introduces lexical variables using name/value pairs, then returns the last expression.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=LET(name1, name_value1, [name2, name_value2, ...], calculation)

Arguments

ArgumentTypeRequiredDefault
name1anyRequired—
name_value1anyRequired—
name2anyOptional—
name_value2anyOptional—
calculationanyRequired—

Accepts a variable number of arguments. Minimum: 3.

Remarks

  • Arguments must be provided as name, value pairs followed by one final calculation expression.
  • Names are resolved as local identifiers and can shadow workbook-level names.
  • Bindings are evaluated left-to-right, so later values can reference earlier bindings.

Error cases

  • Invalid names or malformed arity return #VALUE!.

Examples

Bind a value locally and reuse it in the final calculation.

Formula =LET(total,4,total*3)

Expected result 12

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Bind two local names and use both in the calculation.

Formula =LET(price,4,quantity,3,price*quantity)

Expected result 12

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Bind zero as a valid local value.

Formula =LET(amount,0,amount*3)

Expected result 0

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

An error in the result expression propagates.

Formula =LET(amount,4,amount/0)

Expected result #DIV/0!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Bind intermediate values

Formula =LET(rate,0.08,price,125,price*(1+rate))

Expected result 135

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Use LET with range calculations

Formula =LET(total,SUM(A1:A2),total*2)

Input cells
A
110
24

Expected result 28

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Nested LET supports shadowing

Formula =LET(x,2,LET(x,5,x)+x)

Expected result 7

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

Can a LET binding reference a name defined later in the same LET?

No. LET evaluates name/value pairs left-to-right, so each binding can only use earlier bindings.

Does LET overwrite workbook or worksheet names permanently?

No. LET names are lexical and local to that formula evaluation; they only shadow outer names inside the LET expression.

Is LET itself volatile?

No. LET is deterministic unless one of its bound expressions calls a volatile function such as RAND.

Implementation

Engine source

On this page