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.
- IFSEvaluates multiple conditions and returns a value that corresponds to the first true condition.LogicalExcel
- LETAssigns name with the value_expression results and returns the result of the formula_expression. The formula_expression can use the names defined in the scope of the LET function. The value_expressions are evaluated only once in the LET function even if the following value_expressions or the formula_expression use them multiple times.LogicalExcel
- AVERAGEIFReturns the average of a range depending on criteria.StatisticalExcel
- CELLReturns the requested information about the specified cell.InfoExcel
- CSCReturns the cosecant of an angle provided in radians. .MathExcel
- FILTERReturns a filtered version of the source range, returning only rows or columns which meet the specified conditions.FilterExcel