iff()

Returns the value of then if if evaluates to true, or the value of else otherwise.

The iff() and iif() functions are equivalent

Syntax

iff(if, then, else)

Parameters

NameTypeRequiredDescription
ifstringAn expression that evaluates to a boolean value.
thenscalarAn expression that gets evaluated and its value returned from the function if if evaluates to true.
elsescalarAn expression that gets evaluated and its value returned from the function if if evaluates to false.

Returns

This function returns the value of then if if evaluates to true, or the value of else otherwise.

Example

StormEvents
| extend Rain = iff((EventType in ("Heavy Rain", "Flash Flood", "Flood")), "Rain event", "Not rain event")
| project State, EventId, EventType, Rain

Output

The following table shows only the first 5 rows.

StateEventIdEventTypeRain
ATLANTIC SOUTH61032WaterspoutNot rain event
FLORIDA60904Heavy RainRain event
FLORIDA60913TornadoNot rain event
GEORGIA64588Thunderstorm WindNot rain event
MISSISSIPPI68796Thunderstorm WindNot rain event
............