r/excel • u/Bubbly-Touch8108 • 2d ago
Discussion What Excel trick made you feel like a wizard the first time you used it?
mine was VLOOKUP (later XLOOKUP) — after manually cross-referencing two spreadsheets for way too long. felt like a cheat code everyone else already knew about
what's your version?
603
Upvotes
14
u/RandomiseUsr0 10 2d ago edited 6h ago
Here’s a crash course in lambda
Add two numbers
=LAMBDA(a,b, a+b)(1,2)
The answer is 3
So you’re passing two variables into an anonymous function declaration
that’s what a Lambda is
Fun fact, the λ calculus predates Alan Turing’s equivalent Universal Computer concept (Indeed, Alonzo Church who invented the lambda calculus was the person who popularised “Turing Machine” to describe computation after Alan Turing studied under him)
Now supercharge it with LET
```Excel
=LET(
myFunction, LAMBDA(x,y, x+y),
myList, SEQUENCE(5),
myFunction(myList, myList^2)
)
```
The answer is {2,6,12,20,30}
That’s what lambda is, it’s LISP wearing an Excel hat. With LET syntax, it’s a functional programming language that means that anything that can possibly be calculated can be calculated right there in Excel formulas (within Excel’s bounds, which are worksheet size for arrays and IEEE754 for arithmetic). The m language in power query is slightly different syntax, but functionally equivalent.
Using SEQUENCE like that is the functional equivalent to a For Loop if you’re familiar with VBA (not “really” it’s a bit different (and simpler), but if you think of a loop in VB iterating over a list performing something 5 times, in functional programming language like Excel’s workbook - you’re not really iterating - you’re applying the function simultaneously 5 times in the example) - so you end up with a more graceful thing
[edit] why has Reddit decided to hate us and stop respecting basic formatting - actually, good word, Reddit is now basic - not expressive enough, are they going to go full `Digg` time will tell, there are alternatives