Union (MDX)

 

Updated: March 2, 2016

Returns a set that is generated by the union of two sets, optionally retaining duplicate members.

  
Standard syntax  
Union(Set_Expression1, Set_Expression2 [,...n][, ALL])  
  
Alternate syntax 1  
Set_Expression1 + Set_Expression2 [+...n]  
  
Alternate syntax 2  
{Set_Expression1 , Set_Expression2 [,...n]}  

Set Expression 1
A valid Multidimensional Expressions (MDX) expression that returns a set.

Set Expression 2
A valid Multidimensional Expressions (MDX) expression that returns a set.

This function returns the union of two or more specified sets. With the standard syntax and with alternate syntax 1, duplicates are eliminated by default. With the standard syntax, using the ALL flag keeps duplicates in the joined set. Duplicates are deleted from the tail of the set. With alternate syntax 2, duplicates are always retained.

The following examples demonstrate the behavior of the Union function using each syntax.

Standard syntax, duplicates eliminated

SELECT Union   
   ([Date].[Calendar Year].children  
   , {[Date].[Calendar Year].[CY 2002]}  
   , {[Date].[Calendar Year].[CY 2003]}  
   ) ON 0  
FROM [Adventure Works]  
  

Standard syntax, duplicates retained

SELECT Union   
   ([Date].[Calendar Year].children  
   , {[Date].[Calendar Year].[CY 2002]}  
   , {[Date].[Calendar Year].[CY 2003]}  
   , ALL  
   ) ON 0  
FROM [Adventure Works]  
  

Alternate syntax 1, duplicates eliminated

SELECT   
   [Date].[Calendar Year].children   
   + {[Date].[Calendar Year].[CY 2002]}   
   + {[Date].[Calendar Year].[CY 2003]} ON 0  
FROM [Adventure Works]  
  

Alternate syntax 2, duplicates retained

SELECT   
   {[Date].[Calendar Year].children  
   , [Date].[Calendar Year].[CY 2002]  
   , [Date].[Calendar Year].[CY 2003]} ON 0  
FROM [Adventure Works]  
  

+ (Union) (MDX)
MDX Function Reference (MDX)

Community Additions

ADD
Show: