Home      Functions     Common Solutions      Contact     






MDX Functions:
 
MDX Functions

 
Common Solutions

Common Solutions
 
Resource Links

MDX Books
MDX Related Software
MDX Related Blogs
 
Other Links

Contact Us
 
Microsoft SQL Server Analysis Services Function Page
Function Name: IIf
Category: Value
Description: The IIF function returns one of two values depending on the outcome of the supplied logical test.
Syntax: IIF( «Logical Expression», «object», «object» )
Technet Link: MDX IIf Function




The query below uses the IIF function determine the value of the BoyOrGirl calculated member.
 
WITH
      MEMBER [Measures].[BoyOrGirl] AS
      IIF([Customer].[Customer Geography].CurrentMember.Properties("Gender") = "Male" ,"Boy", "Girl")
SELECT
      {[Measures].[BoyOrGirl]} ON COLUMNS,
      {[Customer].[Customer Geography].[Customer].Members} ON ROWS
FROM
      [Adventure Works]
 
 

 
The following query creates a DayOrMonthLevel calculated member that is populated based on the outcome of the logical test of the IIf function.
 
WITH
      MEMBER [Measures].[DayOrMonthLevel] AS
      IIF([Date].[Fiscal].CurrentMember.Level.Ordinal = 4, "Month Level", "Day Level")
SELECT
      {[Measures].[DayOrMonthLevel]} ON COLUMNS,
      DESCENDANTS([Date].[Fiscal], 4, SELF_AND_AFTER) ON ROWS
FROM
      [Adventure Works]
 
 

 
 

 
Copyright 2008 by MDXpert.com.
 
Terms of Use                              Privacy Statement
 
Site Powered By - WinHost.Com