The LAMBDA function in Google Sheets allows users to define their own custom functions directly within the Google Sheets formula bar. This feature enables complex calculations and data manipulations that were previously only possible by writing custom scripts in Google Apps Script or by using complex combinations of built-in functions.
The basic structure of a LAMBDA function is as follows:
LAMBDA(parameter1, parameter2, ..., expression)
Here's a breakdown of each part of the syntax:
Follow the process below to use the LAMBDA function in Google Sheets.
For example, to add two numbers: type =LAMBDA(a, b, a + b) in a cell, where 'a' and 'b' are the numbers you want to add.
To execute your function, add arguments at the end: =LAMBDA(a, b, a + b)(2, 3).
This returns the sum of 2 and 3.
For more complex formulas, we’ll calculate the average of three numbers: =LAMBDA(a, b, c, (a + b + c) / 3)(5, 10, 15). This calculates the average of 5, 10, and 15.
Use cell references instead of direct numbers: =LAMBDA(a, b, a + b)(A1, B1) adds the values in cells A1 and B1.
Name your LAMBDA function for reuse. Go to Data > Named ranges...,
Then, define a name and click "Done". Use this name instead of the whole expression.
Call your named function in a cell with its parameters: If your addition function is named "add", type =add(A1, B1) to use it.
Check for typos, incorrect cell references, or syntax errors if there are issues. Make sure parameters are correctly utilized.
We hope that you now have a better understanding of how to use the Google Sheets LAMBDA function. If you enjoyed this article, you might also like our article on how to set up image functions in Google Sheets or our article on how to make labels on Google Sheets.