The other day, while doing consulting for one of my customers, I had a strange problem. My customer has data for several KPIs and she wants to display average of top 5 values in the dashboard.
- Now, if she wants average of all values, we can use AVERAGE() formula
- if she wants top 5 values to be highlighted, we can use LARGE() formula and CF.
but average of top 5?
I said what any consultant would say. “It is possible”
After thinking for a while, I found the solution by nesting LARGE() formula with AVERAGE() formula. Like this:
=AVERAGE(LARGE(A1:A10,{1,2,3,4,5}))

There is no need to press CTRL+SHIFT+Enter after this formula and it works fine.
You can use similar formula to get Average of bottom 5 values like this:
=AVERAGE(SMALL(A1:A10,{1,2,3,4,5}))
Now, your home work:
Ok, here is an interesting twist to this formula. My formula works fine as long as the list has at least 5 values in it. But, lets say the input range (a1:a10) is dynamic. That means, it can grow or shrink.
Now, how would you modify this formula so that it works even when there are less than 5 values ?
Go, figure that out. When you are done, come back here and post a comment.














8 Responses to “What is LAMBDA? 4 Practical examples to REALLY understand it”
Thanks so much for this, it's utterly brilliant!
Silly question - I assume LAMDA will work with dynamic arrays?
Very much so. Many of the new functions like MAP only make sense in the context of dynamic arrays and Lambda functions.
As usual, very informative material. Easy to understand and apply!
Thanks for making everyone awesome!
Easy to understand Lambda function through this tutorial. Thanks Chandoo.
I have Officce 365 (updated), but I can't see LAMBDA function. 🙁
I dont see "Office Insider" option in my excel 365.
Another option for First Monday...
=LAMBDA(anydate,WORKDAY.INTL(EOMONTH(anydate,-1),1,"0111111"))
Loving the binary options in WORKDAY.INTL David...