LAMBDA function in Google Sheets
Creates and returns a custom function with a set of names and a formula_expression that uses them. To calculate the formula_expression, you can call the returned function with as many values as the name declares.
=LAMBDA(name, formula_expression)LAMBDA syntax and parameters
Two arguments, two required.
- nameanyRequired
The name to be used inside the formula_expression. This name must be an identifier and resolves to the actual value passed to the custom function returned by LAMBDA.
- formula_expressionanyRequired
The formula to be calculated. It uses names declared in previous parameters.
LAMBDA examples
Formulas you'll actually reuse.
Define a reusable discount calculation and call it immediately:
=LAMBDA(price, qty, price * qty * 0.9)(B2, C2)Result
224.10Clamp a whole column at zero by mapping a LAMBDA over it:
=MAP(B2:B13, LAMBDA(x, MAX(x, 0)))
LAMBDA in Excel
Same name — your formula ports as-is.
Try LAMBDA in the playground
Edit the example — nothing to install.
Preloaded with the LAMBDA formula from Example 1 — change anything and watch it respond.
LAMBDA errors
What they mean — and the fixes.
#CALC!The LAMBDA was entered without being called — add an argument list after the closing parenthesis, or pass it to MAP/BYROW.
Related functions
More ways Google Sheets gets this done.
- ANDReturns true if all of the provided arguments are logically true, and false if any of the provided arguments are logically false.LogicalExcel
- FALSEReturns the logical value `FALSE`.LogicalExcel
- IFReturns one value if a logical expression is `TRUE` and another if it is `FALSE`.LogicalExcel
- IFERRORReturns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.LogicalExcel
- IFNAEvaluates a value. If the value is an #N/A error, returns the specified value. .LogicalExcel
- IFSEvaluates multiple conditions and returns a value that corresponds to the first true condition.LogicalExcel