IF function

Updated 3 weeks ago by Neil

The IF function returns one value if a boolean expression is true and another value if it is false. 

The syntax is:

IF(<logical_test>,<value_if_true>,<value_if_false>)

For these examples, we’ll assume the number field Food_rating has a value of 6. 

Datatype

Example

Output

Text

IF(Food_rating > 5, ”Yummy”, ”Yucky”)

Yummy

Number

IF(Food_rating > 5, 10, 1)

10

Currency

IF(Food_rating > 5, Currency(100, "USD"), Currency(10, "USD"))

$100

Date

IF(Food_rating > 5, today(), today().offset(2, "D"))

IF(Food_rating > 5, Date(1970, 5, 29), Date(2015, 5, 29))

(Today’s date)

5/29/1970

You can also use the IF function when assigning a user to a step, or as a condition for when a step happens or not. 

Use case

Example

Result

Assigning a User

IF(Food_rating > 5, _created_by, _created_by.manager)

True and false values must both either be user fields in the form, or system user fields.

Step assigned to the creator

Step condition

IF(Food_rating>5,true(),false())

Step happens

Nested IF functions

You can have nested IF functions that look like this:

IF(Food_rating>5,”Yummy”,IF(Food_rating>3,”OK”,”Yucky”))

In this case, 

  • If the rating is above 5, it will display “Yummy”.
  • If it is 4 or 5, it will display “OK”.
  • If it is 3 or less, it will display “Yucky”. 


How did we do?