Iif
Returns one of the two numeric or string values determined by the logical test.
Grammar
Digital
IIf («logical expression»,«numeric expression1»,«numeric expression2»)
If «logical expression» evaluates to TRUE, this function returns «numeric expression1», otherwise, returns «numeric expression2».
String
IIf («logical expression»,«string expression1»,«string expression2»)
If «logical expression» evaluates to TRUE, this function returns «string expression1», otherwise, returns «string expression2».
Comments
The expression is considered FALSE only if the value of the «logical expression» is zero. Any other value is interpreted as TRUE.
It is not recommended to use the IIF function to create a collection of members based on search criteria. Instead, use the Filter function to evaluate each member of the specified collection based on a logical expression, and then return a subset of the members.
Example
Digital
If the measures.currentmember is an empty cell, the following example returns 0, otherwise it returns 1:
IIf (IsEmpty (Measures.CurrentMember), 0, 1)
String
If Measures.CurrentMember is an empty cell, the following string returns the string "Yes", otherwise the string "No" is returned:
IIf (IsEmpty (Measures.CurrentMember), "Yes", "No")
In Access I can use the IIf function for statistical totals, for example, to know the number of users who should actually pay the fee:
1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!