# Logic Functions

## Logic Functions

TrackVia has built-in logic functions.  The table below describes how these functions can be used in a calculated field's formula and the inputs that the functions require. In your formulas, these would be:

• Field name inside curly brackets
• Text in quotes
• Number (quotes are optional)
Function Description
if()

if(condition, true result, false result)
Enter a condition, what should return in the field if that condition is true, followed by what should return if the condition is false.
Example: if({Price} > 50, "Expensive", "Inexpensive")

If there are multiple conditions, you can nest if() functions within each other. Here's the syntax when nesting 3 if() functions (4 different results):
if(condition, true result, if(condition, true result, if(condition, true result, false result)))

Note: Do not forget the final false result is needed when nesting if() functions.  Also, a closed parenthesis is required at the end of the formula for each if() function used.
or()

or(condition A, condition B, condition C)
When writing a formula that requires "or" logic (only one or more condition needs to be met), you can enter each within the or() function.
Example: or({Price}=10, {Price}=20, {Price}=30)
and()

and(condition A, condition B)
When writing a formula that requires multiple conditions to be met, you can enter each within the and() function.
Example: and({City}="Denver", {State}="CO")
isblank()

isblank({Field Name})
This function can be used in a logic formula when you need to determine if a field does not have a value (is blank or null).
Example in an if() function: if(isblank({City}), "You need to enter a City", "")

Note: An empty pair of quotation marks indicates to leave the field blank (which is an actual value -- see the null() function below)
not()

The not() function serves to invert any other function or logical condition in a formula.  In other words, it reverses the argument.  This function is commonly wrapped around the isblank() function (above) to determine if a field is not blank.

For example, the not() function is convenient if you want to quickly switch your logic around in an if() function:

if(not(isblank({City})), null(), "You need to enter a City")
null()

The null() function can be used on it's own as a result in a logic formula. This function is commonly used in an if() function to return nothing in a field if a condition is not met.  Example:  if({Price} > 50, "Sell", null() )

Note: In the example above, any field that does not meet the condition will display as "Blank" in both Quick Filters and Saved Filters.  This is contrary to using double quotations ("") as the False condition, meaning that the field is empty, but not blank.