LET instead of repeating a fragment
Formulas & calculation
The rule
When an expression appears more than once inside a formula, bind it with LET and reference the name.
Why it matters
Repeated fragments cost you twice. Excel evaluates that repeated XLOOKUP on every calculation, and when the lookup needs to change you have to change it in both places. Eventually you’ll change it in one.
LET fixes both problems, and it does something more useful than either. It lets you name intermediate results inside a formula, so the formula explains itself to the next reader.
How to do it
=LET(
base, XLOOKUP($B12, Map[Code], Map[Rate]),
volume, SUMIFS(Data[Units], Data[Code], $B12, Data[Month], F$8),
base * volume
)
Put each binding on its own line with Alt+Enter. The formula bar becomes readable, and the last argument, which is the actual result, sits alone at the bottom where you can find it.
The exception
If the LET is getting long enough to need scrolling, the right answer was helper rows. LET reduces repetition. It doesn’t license complexity.
