Name

if — Return alternate values depending on the value of a condition.

Syntax

if(condition, trueclause, falseclause)
              

The IF function has the following arguments:

condition

The condition to be evaluated.

trueclause

The clause to be evaluated and returned if the condition is true.

falseclause

The clause to be evaluated and returned if the condition is false.

Description

First evaluate the condition clause, and if the result is true then evaluate and return the true clause. Otherwise evaluate and return the false clause.

The true clause and false clause must return the same data types.

Examples

Formula

Description

Result

if(10 < 100, 'a', 'b')

Test the condition and then evaluate and return the appropriate clause.'a'
if(100 < 10, 'a', if('a' = lower('A'), 'b', 'c'))An example of a nested if statement

'b'