Skip to content

Logic and Conditionals

Calculated fields support conditional functions and logical operators as follows:

IF *condition* THEN *value if true* ELSE *value if false* END

Boolean Constants

  • TRUE
  • FALSE
IF TRUE THEN "Happy" ELSE "Sad" END = "Happy"  
IF FALSE THEN "Happy" ELSE "Sad" END = "Sad"

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
IF 1 = 1 THEN "Happy" ELSE "Sad" END = "Happy"  
IF 1 = 2 THEN "Happy" ELSE "Sad" END = "Sad"   

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:

IF EMPTY(["Job Status"]) THEN "Status Not Set" ELSE "Status Is Set"    

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:

IF FALSE THEN  
    IF TRUE THEN 66 ELSE 55 END  
ELSE  
    IF TRUE THEN 44 ELSE 33 END  
END = 44

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.