Skip to main content

IF

Tom Williams avatar
Written by Tom Williams
Updated over a week ago

Type: Function

Function: IF

Syntax: IF(condition, value_if_true, [value_if_false]) or alternatively, the shorthand version condition ? value_if_true : value_if_false

Description: If the first argument evaluates to true then it returns the second argument, otherwise, it returns the third argument (or null if none is provided). The second and the third arguments must have the same type.

The IF operator also supports the if/elseif/...elseif/else syntax. Simply provide additional condition, value_if_true pairs to do so. E.g. IF(condition1, value_if_condition1, condition2, value_if_condition2, ..., else_value)

In this form the IF operator returns the value corresponding to the first matching condition. If no conditions are matched then the else_value is returned (or null if none is specified).

Sample usage:

  • IF(updated_at > created_at, updated_at, created_at) will always return updated_at by definition

  • IF(1 > 2, "some result")returns null

  • lines_changed > 500 ? "Big PR" : "Small PR" returns “Big PR” for all pull requests with more than 500 lines of code changed and “Small PR” otherwise.

  • IF(CONTAINS(label_names, ["defect", "bug", "fix"]), "Bug ", "Feature") returns Bug if one of the defined labels is found, otherwise returns Feature. This is used to remap fields.

  • IF(false, "not me", true, "me!", false, "too late") returns "me!" as it is the value corresponding to the first truthy condition.

  • IF(false, "not me", false, "not me", false, "not me", "me then!") returns "me then!" as the else_value since none of the previous conditions evaluated to true.

Did this answer your question?