Excel Function: LAMBDA

The LAMBDA function allows you to create custom and reusable functions.

Furthermore, when used with some other functions such as MAP and REDUCE, it allows you to create powerful formulas.

Usage:

=LAMBDA(parameter, calculation)

or

=LAMBDA(parameter1, parameter2, ..., calculation)


Understanding this function

The goal here will be to create a simple function that will triple the quantity:

excel function triple lambda

Enter in the LAMBDA function:

The formula to triple the quantity is:

=LAMBDA(number,number*3)

The LAMBDA function indeed returns the created function, but since no number has been passed as an argument, it cannot return a result:

excel function lambda error calc

When you use other Excel functions, you start by entering the function (for example AVERAGE), then in parentheses the argument(s).

With LAMBDA it's the same, enter the function (here LAMBDA(number,number*3)), then in parentheses the argument required by the function:

=LAMBDA(number,number*3)(A2)
excel function lambda argument

Of course we could also have done the same calculation by entering =A2*3 but the objective was to take a simple example.

Custom function

To facilitate its use, you can save and name your custom function.

In the Formulas ribbon, click on Name Manager:

excel function name manager lambda

Click on New, enter the name of the new function (for example "TRIPLE_QUANTITY") and the formula with LAMBDA:

excel create custom function lambda

You can then easily use the new created function:

excel insert custom function lambda

And this will avoid you entering the LAMBDA function each time:

=TRIPLE_QUANTITY(A2)
excel function custom lambda
Another example of a custom function is available on the page: custom function

Function combinations

The LAMBDA function is necessary for the operation of some other functions and allows to create powerful formulas.

These other functions are:

Staying with this same simple example (which triples the quantity), using LAMBDA with the function MAP allows you to calculate the result for an entire range in a single formula:

=MAP(A2:A8,LAMBDA(number,number*3))
excel function lambda map

If you have created a custom function, simply enter the name of the function:

=MAP(A2:A8,TRIPLE_QUANTITY)
excel function custom map lambda
If needed, you can download the Excel file used here: lambda.xlsx
Note: this function is only available with Office 365.