What is LAMBDA function in Excel?
The LAMBDA function just came out yesterday in Microsoft 365. What LAMBDA does is let us create some variables and then our own function. We copy and paste this, go up to Formulas, and create a Defined Name, and then that function can be used anywhere.
LAMBDA function in worksheet.
For example, if I define the variables start, comma, end, in, comma, those are the two variables, and then I say n divided by start minus 1. That's the formula for percentage change. Now we can test it right here in the worksheet by using open parentheses, which is what we'll have to do when we actually use this as a Defined Name. Start is going to be 100, and the end value will be 110, so that should give us 10 percent, and it does.
LAMBDA function as reusable function (Defined Name with inputs).
Now when we put this into Defined Names, I simply copy, click Name Manager or Control+F3, New. The name of this LAMBDA function I'm going to call decimal change, and then down in Refers to, I'm going to Control+V, click OK. Now we can come back later if we need to edit.
So now I simply say equals, and then I'm going to find the Defined Name, open parentheses, 100, that's the start, comma, 110, that'll be the finish, and when I hit Enter, that's the result.
Edit LAMBDA function as Defined Name.
Control+F3 if you need to edit. For example, let's say that we want to always return this formatted as a percent and as a text value. I could add the TEXT function, comma, and then in double quotes we put the custom number format 0.00 percent in double quotes, close parentheses. Now when I click OK and click Close, that is amazing.
LAMBDA for the end user
Then later you could have some instructions for a user with formula inputs, and then we simply use our Defined Name, open parentheses. I'm going to up arrow to get the input, comma, there's start, and then n, close parentheses, and that is amazing.
LET and LAMBDA together to make complex reporting simple for the end user.
Now what I really want to show you is LAMBDA with LET. Over the last year or so we've been doing a lot of LET formulas to create single cell reports. Watch this. I'm just going to copy this, and that's a bunch of complicated stuff, right? But we want to use LAMBDA and the Defined Name to make it easy for someone to create this report by only entering the three columns.
So I'm going to copy this, come down, equals LAMBDA, and just for simplicity I'm going to say dd, that's going to be for the date column, comma, pp for the person column, comma, ss for the sales column, comma, and there's our calculation. Control+V. Very carefully I'm going to highlight that, because originally in LET it was an input. Now I'm going to call it dd, so that will be this variable right there. This one for the person column will be pp, and this one for the sales column will be ss.
Now we can test it right here. I have to come to the end, close parentheses, and then we can test it there. It is open parentheses, and then we want to highlight the columns: date, comma, person, comma, sales, close parentheses. It looks like right there I better backspace, and now when I hit Enter, that is amazing.
Let's copy the whole LAMBDA LET without the parameters at the end, Control+C, Control+F3, New, and I'm going to call it something like Person End of Month Report. I want to put some comments here, so I just described what they have to do: entering the three columns separated by commas. Now I come down here, Control+V, click OK, click Close.
Now down below, equals, and we'll find our Defined Name, open parentheses, date, comma, person, comma, sales, close parentheses, and you are not going to believe that I don't have the formatting here, but I am amazed. So we can create complicated single cell reports which are as dynamic as their formulas by using the LET function and then putting it inside of LAMBDA. Wow, LAMBDA is amazing, either with using LET or creating your own function that you can use over and over.
