Over 10 years we help companies reach their financial and branding goals. Maxbizz is a values-driven consulting agency dedicated.

Gallery

Contact

+1-800-456-478-23

411 University St, Seattle

maxbizz@mail.com

What is LAMBDA? 4 Practical examples to REALLY understand it

Ladies & gentlemen… Excel has a new function. LAMBDA()  is the new addition to Excel’s family of functions. Using LAMBDA, we can create custom & reusable functions in Excel. 

In this article, learn all about:

LAMBDA() and other lambda helper functions are available in below formats of Excel only.

LAMBDA (pronounced lam-duh) allows us to write our own functions and add them to the library. 

For example, here is a very simple LAMBDA to subtract one value from another.

To call this LAMBDA, you can use the below syntax.

Here is a quick demo of our subtraction LAMBDA…

The TRUE Power of LAMBDA is unleashed once you “install” or “setup” them. To install out subtract lambda, 

To call the lambda, just go to any cell and type the =subtract formula and provide parameters a & b as you normally would.

Here is a quick demo of the LAMBDA setup process.

Let’s be honest. No one needs the SUBTRACT function. We can already do that with the – (minus) operator. So in this part of the article, let me present some practical LAMBDAs. 

 

Calculating weighted averages is a pain in Excel. There is no built-in function to do the task. Well, we can make our own WAVERAGE() function, thanks to LAMBDA().

Define WAVERAGE name as

=LAMBDA(values, weights, SUMPRODUCT(values, weights)/ SUM(weights))

Here is how you can use it to correctly calculate weighted average of salaries.

Let’s say you have a list of values and just want to get the “topn” values in descending order. We can set up a LAMBDA to do that magic.

Define TOPN name as

=LAMBDA(values, n, LARGE(values, SEQUENCE(n)))

We can call this LAMBDA like:

=TOPN(a1:a10, 3) to see top 3 values in the range A1:A10.

Excel has the excellent TODAY() function to tell me what is the current date. But there is no TOMORROW()?

Let’s fix that with LAMBDA.

Define the name tomorrow as,

=LAMBDA(TODAY()+1)

And, you can call it by writing =TOMORROW() in any cell. Works like magic…

You can write complex Date logic to figure that out. But who wants to write the same formulas every time. This is the job for LAMBDA.

Define FirstMonday as,

=LAMBDA(anydate,
LET(som, DATE(YEAR(anydate),MONTH(anydate),1), CHOOSE(WEEKDAY(som),1,0,6,5,4,3,2)+som))

And to get the first Monday of any month, you can use =FIRSTMONDAY(any date)

For example, =FIRSTMONDAY(“1-jan-2022”) will be 3-Jan-2022 (which is the first monday).

Calculating weighted averages is a pain in Excel. There is no built-in function to do the task. Well, we can make our own WAVERAGE() function, thanks to LAMBDA().

Define WAVERAGE name as

Let’s say you have a list of values and just want to get the “topn” values in descending order. We can set up a LAMBDA to do that magic.

Define TOPN name as

=LAMBDA(values, n, LARGE(values, SEQUENCE(n)))

We can call this LAMBDA like:

=TOPN(a1:a10, 3) to see top 3 values in the range A1:A10.”}},{“@type”:”Question”,”name”:”Tomorrow”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”

Excel has the excellent TODAY() function to tell me what is the current date. But there is no TOMORROW()?

Let’s fix that with LAMBDA.

Define the name tomorrow as,

=LAMBDA(TODAY()+1)

And, you can call it by writing =TOMORROW() in any cell. Works like magic…”}},{“@type”:”Question”,”name”:”First Monday of the Month”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”

You can write complex Date logic to figure that out. But who wants to write the same formulas every time. This is the job for LAMBDA.

Define FirstMonday as,

=LAMBDA(anydate,
LET(som, DATE(YEAR(anydate),MONTH(anydate),1), CHOOSE(WEEKDAY(som),1,0,6,5,4,3,2)+som))

And to get the first Monday of any month, you can use =FIRSTMONDAY(any date)

For example, =FIRSTMONDAY(“1-jan-2022”) will be 3-Jan-2022 (which is theu00a0first monday).”}}]}

We can call this LAMBDA like:

=TOPN(a1:a10, 3) to see top 3 values in the range A1:A10.”}},{“@type”:”Question”,”name”:”Tomorrow”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”

Excel has the excellent TODAY() function to tell me what is the current date. But there is no TOMORROW()?

Let’s fix that with LAMBDA.

Define the name tomorrow as,

=LAMBDA(TODAY()+1)

And, you can call it by writing =TOMORROW() in any cell. Works like magic…”}},{“@type”:”Question”,”name”:”First Monday of the Month”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”

You can write complex Date logic to figure that out. But who wants to write the same formulas every time. This is the job for LAMBDA.

Define FirstMonday as,

=LAMBDA(anydate,
LET(som, DATE(YEAR(anydate),MONTH(anydate),1), CHOOSE(WEEKDAY(som),1,0,6,5,4,3,2)+som))

And to get the first Monday of any month, you can use =FIRSTMONDAY(any date)

For example, =FIRSTMONDAY(“1-jan-2022”) will be 3-Jan-2022 (which is theu00a0first monday).”}}]}

And, you can call it by writing =TOMORROW() in any cell. Works like magic…”}},{“@type”:”Question”,”name”:”First Monday of the Month”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”

You can write complex Date logic to figure that out. But who wants to write the same formulas every time. This is the job for LAMBDA.

Define FirstMonday as,

=LAMBDA(anydate,
LET(som, DATE(YEAR(anydate),MONTH(anydate),1), CHOOSE(WEEKDAY(som),1,0,6,5,4,3,2)+som))

And to get the first Monday of any month, you can use =FIRSTMONDAY(any date)

For example, =FIRSTMONDAY(“1-jan-2022”) will be 3-Jan-2022 (which is theu00a0first monday).”}}]}

And to get the first Monday of any month, you can use =FIRSTMONDAY(any date)

For example, =FIRSTMONDAY(“1-jan-2022”) will be 3-Jan-2022 (which is theu00a0first monday).”}}]}

Apart from LAMBDA, Microsoft also introduced a bunch of helper functions so we can truly build any kind of LAMBDAs in Excel.

These are,

By default, any LAMBDA you create is only available in the workbook. To share LAMBDAs across files or with other users, you can try:

Seasoned users of Excel know that we already have the ability to create and share our own functions. It is called user defined functions (or UDFs). 

Here are some points on how UDFs compare with LAMBDA.

 

For more information about LAMBDA, please read below pages too:

The post What is LAMBDA? 4 Practical examples to REALLY understand it appeared first on Chandoo.org – Learn Excel, Power BI & Charting Online.

source

Author

Joseph Muongi

Financial.co.ke was founded by Mr. Joseph Muongi Kamau. He holds a Master of Science in Finance, Bachelors of Science in Actuarial Science and a Certificate of proficiencty in insurance. He's also the lead financial consultant.