IIf

Syntax

IIf(Logical_expression[, ValueTrue[, ValueFalse])

Parameters

Logical_expression. It determines the condition checked by this function.

ValueTrue. It determines value if the condition is True. Optional parameter.

ValueFalse. It determines value if the condition is False. Optional parameter.

Description

It checks the condition.

NOTE. If several conditions should be checked, use the function per condition.

Comments

The IIf function is equivalent to the ?: conditional statement that can also be used in regular report.

Difference of the IIf function from the ?: statement:

IIf Firstly calculates values of Logical_expression, ValueTrue, ValueFalse, and then depending on the result of Logical_expression returns value ValueTrue or ValueFalse.

Example

Formula Result Description
=IIf(C0>B0, C0, B0) 7 It compares values in the C0, B0 cells and returns the greatest value. The C0 cell contains value 7, the B0 cell contains value 2.
=IIf(C0>B0, A0+2, A0-2) 2 It compares values in the C0, B0 cells and returns value of the A0 cell multiplied by two, the C0 cell contains value 6, the B0 cell contains value 5, the A0 cell contains value 0.
If value in the C0 cell were less than that in the B0 cell, the function would return value of the A0 cell reduced by two.
=IIf(C0>B0, "Yes", "No") Yes Condition checking result: value in the C0 cell is greater than that in the B0 cell. The C0 cell contains value 6, the B0 cell contains value 5.

See also:

Function Wizard │ Logical Functions