IF function
The IF function returns one value if a boolean expression is true and another 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 six.
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 whether a step occurs.
Use case |
Example |
Result |
Assigning a User |
IF(Food_rating > 5, _created_by, _created_by.manager) True and false values must either be user or system user fields in the form. |
Step assigned to the creator |
Step condition |
IF(Food_rating>5,true(),false()) |
Step happens |
Nested IF functions
You can use 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, Yummy.
- If it is 4 or 5, OK.
- If it is 3 or less, Yucky.