IIf
Returns one of two numeric or string values determined by a logical test.
Syntax
Numeric
IIf(«Logical Expression», «Numeric Expression1», «Numeric Expression2»)
This function returns «Numeric Expression1» if «Logical Expression» evaluates to TRUE, otherwise returns «Numeric Expression2».
String
IIf(«Logical Expression», «String Expression1», «String Expression2»)
This function returns «String Expression1» if «Logical Expression» evaluates to TRUE, otherwise returns «String Expression2».
Remarks
«Logical Expression» is considered to be FALSE only if its value is zero. Any other value is interpreted as TRUE.
The Iif function is not recommended for creating a set of members based on search criteria. Instead, use the Filter function to evaluate each member in a specified set against a logical expression and return a subset of members.
Examples
Numeric
The following example returns 0
if Measures.CurrentMember is an empty cell, 1
otherwise:
IIf(IsEmpty(Measures.CurrentMember), 0, 1)
String
The following string returns the string "Yes"
if Measures.CurrentMember is an empty cell, the string, "No"
otherwise:
IIf(IsEmpty(Measures.CurrentMember), "Yes", "No")