|
|
The IIF function allows you to return one of two values based on a logical expression (if, then, else) in a calculated field.
Syntax The Syntax of the IIF function is as follows:
IIF (expression, truePart, falsePart)
|
|
Arguments |
|
expression |
is a Boolean expression. |
truePart |
is the value returned if expression is True. It can be any simple type (Number, Currency, String, Boolean, Date, Time or DateTime) or range type (Number Range, Currency Range, String Range, Date Range, Time Range or DateTime Range), but it may not be an array. |
falsePart |
is the value returned if expression is False. It must be of the same type as truePart. Returns |
Action IIF returns one of two parts, depending on the evaluation of the expression.
Typical uses IIF can be used as an alternative to the If/Then/Else control structure in the expression builder.
Examples IIF (ReportData("Order Amount") > 10000, "large order", "standard order")
Returns the String value “large order” if Order Amount is more than $10,000 and the String value “standard order” otherwise.
Comments Every argument of the IIF function is evaluated before the result is returned. Thus, you should watch out for undesirable side effects when using IIF. For example, if falsePart results in division by zero, an error will occur, even if expression is True and so truePart is returned. |
|