Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Union (MDX)
Collapse the table of content
Expand the table of content

Union (MDX)

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]

Community Additions

ADD
Show:
© 2015 Microsoft