LET ^v3.3.8
Gives names to values, then returns the result of the final expression, which can use those names. Use it to calculate a value once and reuse it, instead of repeating the same expression.
Each value is calculated once, in order, and can use the names declared before it. Names only exist inside the LET.
js
LET(name, value, ...name_value, result)Parameters
name- The name for the value, in quotes. Use letters, digits and underscores, and don't start with a digit.value- Any expression. Its result is stored under the name.name_value- Morename, valuepairs, as many as you need. A value can use any name declared before it.(optional)result- The expression to return. It can use every name.
Examples
js
LET("a", 5, "b", a * 2, b + a)Result: 15
Note: a is 5 and b is 10, so the result is 15.
js
LET("total", ["Hours"] * ["Rate"], IF(total = 0, 0, ROUND(total * 1.2, 2)))Note: Hours times rate is calculated once and used in both the condition and the result.
TIP
Write each name in quotes where you declare it, then use it without quotes, like LET("a", 5, a * 2). Names aren't case-sensitive. A name can't be used before its name, value pair, including inside its own value.
Keep LET close to where it's used
LET works out all its values up front, even ones the result might not need. For the best performance, wrap just the part of the formula that reuses a value, rather than the whole formula.