Logic and Conditionals
Calculated fields support conditional functions and logical operators as follows:
Boolean Constants
- TRUE
- FALSE
Logical Operators
- AND
- NOT
- OR
- XOR (one or the other is true but not both)
IF TRUE AND TRUE THEN "Happy" ELSE "Sad" END = "Happy"
IF TRUE AND FALSE THEN "Happy" ELSE "Sad" END = "Sad"
Comparison Operators
- = Equal
- > Greater Than
- >= Greater Than or Equal
- < Less Than
- <= Less Than or Equal
- <> Not Equal
Empty Values
Sometimes you want to know if a field or value is "empty". For this purpose,
"empty" means the value is "null" or an empty string "".
IF EMPTY("ABC") THEN "Empty" ELSE "Not Empty" END = "Not Empty"
IF EMPTY("") THEN "Empty" ELSE "Not Empty" END = "Empty"
It is particularly useful when working with Existing Fields:
Note
Only null values or empty strings count as "Empty".
Other "falsy" values, like: 0, -1, "false", "No", etc.
are all considered "Not Empty"
Examples
Conditionals can be nested to any depth:
They can also contain nested calculations:
IF 1 + 1 = 2 THEN "Happy" ELSE "Sad" END = "Happy"
IF (1 + 1) >= 2 * (8 + 6) THEN "Happy" ELSE "Sad" END = "Sad"
Note: Comparison operators are strictly typed. In other words, you can't compare a string to an integer.