Have You Heard of Formula Variables?

Tips & Tricks
Jan 10, 2008
2 Min Read

QuickBase introduced a lot of new screens and features to the product last spring, including some formula field enhancements. Amid all the changes, one useful feature didn't get the attention it deserves: formula variables.

Did you know that you can use variables within a formula? This feature is a great way to save typing within a very long formula. If your formula is complex, variables also help you simplify the code. This makes the formula easier to read and troubleshoot.

For example, say you've got this string:

[Price] * [Quantity]

that needs to appear multiple times within your formula, like this:

if ([Price] * [Quantity] > 100, [Price] * [Quantity] *
0.9, [Price] * [Quantity])

You can define a variable to stand in for that string. Say you call that variable total.

Replace the code snippet with that variable (using a $ dollar sign to denote the variable), and your formula becomes much shorter:

if ($total > 100, $total * 0.9, $total)

Isn't that tidy?

Actually, you need to include your variable definition within the formula itself, so really the entire formula would look like this:

var Number total = [Price] * [Quantity] ;

if ($total > 100, $total * 0.9, $total)

To learn more and see other examples, please read the help topic on formula variables

Hope this helps all you formula authors out there...

Recomended Posts