Export (0) Print
Expand All
Avg
IIf
Lag
Max
Min
Mtd
Qtd
Sum
Var
Wtd
Ytd
Expand Minimize

Union (MDX)

Updated: 17 July 2006

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.

Examples

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]

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.
  • Added updated examples.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft