HomeLAMBDA Function in Google SheetsFormulas & FunctionsLAMBDA Function in Google Sheets

LAMBDA Function in Google Sheets

LAMBDA function tutorials offer the ultimate spreadsheet savior when you want to create custom, reusable functions with placeholder inputs in Google Sheets. Whether you are building complex calculations or powering advanced named functions and helper functions like MAP and REDUCE, mastering this capability brings programming-level flexibility to your spreadsheets without manual redundancy.

Advanced spreadsheet formulas packed with high-efficiency syntax, placeholder structures, and entirely free of repetitive formula writing elevate your data management while keeping your workflows streamlined.

LAMBDA functions are also the underlying technology for Named Functions, which are hugely useful.

LAMBDA functions themselves are challenging to use and not very intuitive compared to regular functions.

Lambda Function In Google Sheets

🔗 Get this example and others in the template at the bottom of this article.

Simple LAMBDA Function Example

We’ll start with the simplest LAMBDA function we can: a custom function to double a number.

I.e. x => 2x

The LAMBDA formula to double a number is:

=LAMBDA(x,x*2)(A1)

It works like so:

simple Lambda Function In Google Sheets

Of course, it’s much easier to simply type =A1 * 2 so this lambda is just to illustrate how it works.

LAMBDA Function in Google Sheets: Syntax

The LAMBDA function takes one or more arguments:

=LAMBDA([name,...], formula_expression)

[name,...]

This is optional and repeatable and represents the placeholders to use inside your formula.

formula_expression

The formula definition to calculate. It can reference any placeholder names that have been defined.

Notes on using the LAMBDA Function

The LAMBDA function is the only function that takes two sets of brackets for inputs, i.e. it takes the form

=LAMBDA(...)(...)

where the first set of brackets define LAMBDA and the second set are the actual input values you want to use.

If you try to use LAMBDA without adding actual values or cell references after the definition, you’ll see the following error:

lambda Formula Error

LAMBDA Percent Change Example

Suppose we have a table of quarterly financial data.

We want to calculate the percent change between 2021 and 2022, using this formula:

=(C2-B2)/B2

Which gives the following output:

Percent Change Formula

We can convert this to a LAMBDA formula by first defining the placeholders, then the function expression, and then supplying the actual values:

=LAMBDA(oldVal,newVal,(newVal-oldVal)/oldVal)(B2,C2)

Has that helped us?

No, not really!

The LAMBDA formula is more complex than the original formula.

So, instead of a LAMBDA function, we could create a named function PERCENTCHANGE and use it as follows:

=PERCENTCHANGE(B2,C2)

LAMBDA Helper Functions

As I mentioned earlier in this post, the main use case for the LAMBDA function is to work with the lambda helper functions:

  • MAP: Returns a new array formed by mapping each value in array_or_range to a new value
  • REDUCE: Reduces an array_or_range by repeatedly applying a lambda to each value in array_or_range
  • BYCOL: Returns a new row array formed by grouping each column in array_or_range to a single value
  • BYROW: Returns a new column array formed by grouping each row in array_or_range to a single value
  • SCAN: Scans array_or_range by repeatedly applying a lambda to each value in array_or_range
  • MAKEARRAY: Returns a calculated array of specified rows and columns

Also Read : How to Create a Google Sheets Pivot Table

Leave a Reply

Your email address will not be published. Required fields are marked *