iff()
Returns the value of then if if evaluates to true
,
or the value of else otherwise.
The
iff()
andiif()
functions are equivalent
Syntax
iff(
if,
then,
else)
Parameters
Name | Type | Required | Description |
---|---|---|---|
if | string | ✓ | An expression that evaluates to a boolean value. |
then | scalar | ✓ | An expression that gets evaluated and its value returned from the function if if evaluates to true . |
else | scalar | ✓ | An 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.
State | EventId | EventType | Rain |
---|---|---|---|
ATLANTIC SOUTH | 61032 | Waterspout | Not rain event |
FLORIDA | 60904 | Heavy Rain | Rain event |
FLORIDA | 60913 | Tornado | Not rain event |
GEORGIA | 64588 | Thunderstorm Wind | Not rain event |
MISSISSIPPI | 68796 | Thunderstorm Wind | Not rain event |
... | ... | ... | ... |