The LAMBDA function in Google Sheets empowers users to create custom spreadsheet functions tailored to their specific needs. By encapsulating complex calculations into a reusable format, LAMBDA simplifies workflows and improves efficiency. This function enables users to define names and expressions, enhancing the flexibility of data manipulation and analysis within their spreadsheets.
Syntax
LAMBDA(name1, name2, ..., formula_expression)
- name1, name2, …: These are the names of the parameters you define for your custom function.
- formula_expression: This is the expression or calculation that uses the defined names to produce a result.
Example #1
=LAMBDA(x, y, x + y)(5, 3)
This function takes two parameters, adds them together, and returns the result. The output here would be 8.
Example #2
=LAMBDA(a, b, a b)(4, 7)
This function multiplies the two inputs. The result would be 28.
Example #3
=LAMBDA(text, len, LEFT(text, len))("Hello, World!", 5)
This function extracts the first five characters of a string. The output will be Hello.
Error handling
- VALUE!: This error occurs when the number of arguments provided does not match the number of names defined in the LAMBDA function.
- NAME?: This error indicates that the function name is not recognized, often due to a misspelling or formatting issue in the function call.
- REF!: This error appears if the LAMBDA function references a range or cell that is invalid.