LAMBDA function

LAMBDA lets you create custom, reusable functions directly in a cell, returning any value or array based on supplied parameters.

=LAMBDA(parameter1, ..., calculation)

Generate a LAMBDA formula

Describe what you need. The generator will reach for LAMBDA where LAMBDA is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How LAMBDA reads its arguments
parameter1requiredcalculationrequiredLAMBDA
ArgumentRequiredDescription
parameter1RequiredThe first required argument; can be any type (range, scalar, array) that the calculation will use; if omitted the function returns #VALUE!.
...RepeatingOptional repeating parameters; each may be any data type and are passed to the calculation in order; excess arguments are ignored, missing ones become #N/A.
calculationRequiredA required expression that uses the supplied parameters to produce a result; must be a valid formula; if it evaluates to an error the LAMBDA returns that error.

Returns

It returns a scalar, array, or error value matching the shape produced by the calculation.

Availability

Excel: 365 · Google Sheets: Supported

Worked examples

1. Average list price of all listings

AddressBedsBathsList PriceDays on Market
123 Maple St3230000045
456 Oak Ave4345000030
789 Pine Rd2125000060
321 Birch Blvd5460000015
=LAMBDA(tbl, AVERAGE(INDEX(tbl,,4)))(A2:E6)

Result: 400000

The LAMBDA receives the whole table (A2:E6) as its single parameter tbl. Inside the calculation, INDEX(tbl,,4) extracts the fourth column – the list prices – and AVERAGE computes their mean. The four prices sum to 1,600,000, so the average is 400,000, which the formula returns.

2. Address of the property that has lingered longest on the market

AddressBedsBathsList PriceDays on Market
123 Maple St3230000045
456 Oak Ave4345000030
789 Pine Rd2125000060
321 Birch Blvd5460000015
=LAMBDA(tbl, INDEX(tbl, MATCH(MAX(INDEX(tbl,,5)), INDEX(tbl,,5),0),1))(A2:E6)

Result: 789 Pine Rd

The calculation first pulls the fifth column (days on market) with INDEX(tbl,,5) and finds its maximum (60). MATCH then locates the row where 60 appears. Finally INDEX returns the value from column one of that row – the address "789 Pine Rd" – which is the result.

3. Price per bed for each listing using MAP and LAMBDA

AddressBedsBathsList PriceDays on Market
123 Maple St3230000045
456 Oak Ave4345000030
789 Pine Rd2125000060
321 Birch Blvd5460000015
=MAP(A2:E6, LAMBDA(row, INDEX(row,4)/INDEX(row,2)))

Result: 100000112500125000120000

MAP iterates over each row of the table. The embedded LAMBDA receives a single row, extracts the list price (column 4) and the bed count (column 2), divides price by beds, and returns the per-bed price. The four calculations yield 100,000; 112,500; 125,000; and 120,000, returned as a vertical array.

Common errors

Which LAMBDA error are you seeing?
LAMBDA returned an error#NAME?
Upgrade to Excel 365 (or later) or enable the LAMBDA preview in Google Sheets; then the function will be parsed correctly.
#VALUE!
Provide all required arguments – at least one parameter and the calculation – or adjust the LAMBDA definition to match the number of arguments you intend to pass.
#REF!
Correct the range reference to point to an existing range, or use dynamic functions like OFFSET or INDEX that adapt to the current size of the data.
ErrorWhy it happensHow to fix it
#NAME?LAMBDA is not recognized because the workbook is opened in a version of Excel that predates the 365 rollout or in Google Sheets that has the feature disabled.Upgrade to Excel 365 (or later) or enable the LAMBDA preview in Google Sheets; then the function will be parsed correctly.
#VALUE!The LAMBDA call supplies fewer arguments than the defined parameters, for example omitting the required calculation expression.Provide all required arguments – at least one parameter and the calculation – or adjust the LAMBDA definition to match the number of arguments you intend to pass.
#REF!Inside the LAMBDA the formula references a range that has been deleted, moved, or is otherwise invalid, such as A1000:E1000 in a sheet that only has 500 rows.Correct the range reference to point to an existing range, or use dynamic functions like OFFSET or INDEX that adapt to the current size of the data.

Tips and when to use something else

  • Wrap complex logic in LAMBDA and then reuse it with LET to keep your workbook tidy.
  • When you need to apply a LAMBDA across many rows or columns, combine it with MAP, BYROW, or BYCOL for vectorised execution.
  • If you only need a one-off calculation without reusability, a plain formula with LET is often simpler than defining a separate LAMBDA.
  • For look-up scenarios, consider XLOOKUP or VLOOKUP instead of writing a custom search LAMBDA; they are faster and handle missing values automatically.

Frequently asked questions

How do I create a reusable custom function with LAMBDA in Excel?
Define the LAMBDA once in the Name Manager, giving it a name and the parameter list, then call that name like any built-in function. This lets you maintain the definition centrally and reuse it across worksheets.
Can LAMBDA return an array that spills into multiple cells?
Yes. If the calculation inside LAMBDA produces a multi-cell array, the calling cell will spill the result automatically, provided there is enough empty space. Make sure no other data blocks the spill range.
Why does my LAMBDA formula give #VALUE! even though the logic looks correct?
A common cause is a mismatch between the number of parameters you defined and the number you passed when invoking the function. Double-check that each required argument is supplied, and that optional arguments are either provided or omitted consistently.
Is it possible to nest LAMBDA inside other functions like FILTER or SORT?
Absolutely. LAMBDA can be used as an argument to functions that expect a lambda-style callback, such as MAP, BYROW, BYCOL, FILTER (via a helper LAMBDA), or even inside SORTBY to compute custom sort keys.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17