IIf (MDX)

Returns one of two values determined by a logical test.

Syntax

IIf(Logical_Expression, Expression1, Expression2)

Arguments

  • Logical_Expression
    A valid Multidimensional Expressions (MDX) logical expression that evaluates to true or false.
  • Expression1
    A valid Multidimensional Expressions (MDX) expression.
  • Expression2
    A valid Multidimensional Expressions (MDX) expression.

Remarks

The expression specified by the logical expression evaluates to false only if the value of this expression is zero. Any other value evaluates to true.

If the specified logical expression evaluates to true, the IIf function returns the first expression. Otherwise, the function returns the second expression.

The specified expressions can return values or MDX objects. Furthermore, the specified expressions need not match in type.

Note

In Microsoft SQL Server 2000, Analysis Services supported only numeric and string return types, and the types of specified expressions had to be the same. These restrictions do not apply to SQL Server 2005 Analysis Services (SSAS).

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.

Note

If either expression evaluates to NULL, the result set will be NULL when that condition is met.

See Also

Reference

MDX Function Reference (MDX)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.