IF

Chooses a value based on a condition

Usage

IF(condition, if_true, [if_false])

Parameters

condition

(Required) The condition to evaluate

if_true

(Required) The value to use when the condition evaluates to TRUE

if_false

The value to use when the condition evaluates to FALSE. This is optional

Examples

Example With these variables Result

IF(country = “Canada”, “a Canadian”)

country is "Canada"

“a Canadian”

IF(country = “Canada”, “a Canadian”)

country is "Belgium"

NOTHING

IF(country = “Canada”, “a Canadian”, “a non-Canadian”)

country is "Belgium"

“a non-Canadian”

IF(number > 5, CONCAT(“big number: “, number), “small”)

number is 10

“big number: 10”

IF(nombre > 5, CONCAT(“grand nombre : “, nombre), “un petit nombre”)

nombre is 10

“grand nombre : 10”

More information

If no value is provided for if_false (the third value) and the condition is FALSE, then the IF function returns NOTHING.

See also