Our new release introduces support for the LET function, which enables you to write shorter, more descriptive formulas that run faster.
At its core, LET makes it possible to assign names to values, which can be used in calculations that appear to the right in the same formula.
The best way to demonstrate this is with an example:
The formula above first multiplies the values of the Width and Height fields together and assigns the name Area to the resulting value. It then multiplies this value by 1500, assigning it the name Cost. Finally, it adds 1000 to the Cost value and returns the sum.
The formula above can also be written (Width * Height * 1500) + 1000(Width * Height * 1500) + 1000, which is significantly shorter, but isn’t as descriptive.
LET is primarily useful when you need to repeat formula fragments in a formula, allowing you to assign a single name to the repeating part and then refer back to it. That can make formulas shorter and make apps perform better, as it gives Calcapp less work to do.
LET is also useful when you want your formulas to be self-documenting, so that other people can more easily determine how they work.
If you need to assign names to values that are accessible from any formula, use named values instead (introduced here).
LET works particularly well with action formulas (formulas run in response to buttons being pressed, another new feature). Refer to our full documentation for more on that topic.
LET in Microsoft Excel
Microsoft Excel introduced support for LET back in 2020. Their version differs from the Calcapp version in that you need to use ,; instead of := to separate names from values.
Being able to use :=
is a Calcapp
extension, which we think makes formulas easier to read. You can use
,; instead of :=
if you like. This
may be useful if you copy and paste formulas between Excel and
Calcapp Creator.
LET and arrays
The values you use with LET can be of any type, including arrays. This formula returns the array elements that are greater than 3:
The version without LET would involve repeating the array:
You can also filter an array without repeating it, and without using LET, using a feature specific to Calcapp:
Be sure to check out our full documentation for more on LET, including lots of formula samples.