title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | ms.custom |
---|---|---|---|---|---|---|---|---|---|
Union (MDX) |
Union (MDX) |
kfollis |
kfollis |
kfollis |
02/17/2022 |
sql |
analysis-services |
reference |
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.
The following examples demonstrate the behavior of the Union function using each syntax.
SELECT Union
([Date].[Calendar Year].children
, {[Date].[Calendar Year].[CY 2002]}
, {[Date].[Calendar Year].[CY 2003]}
) ON 0
FROM [Adventure Works]
SELECT Union
([Date].[Calendar Year].children
, {[Date].[Calendar Year].[CY 2002]}
, {[Date].[Calendar Year].[CY 2003]}
, ALL
) ON 0
FROM [Adventure Works]
SELECT
[Date].[Calendar Year].children
+ {[Date].[Calendar Year].[CY 2002]}
+ {[Date].[Calendar Year].[CY 2003]} ON 0
FROM [Adventure Works]
SELECT
{[Date].[Calendar Year].children
, [Date].[Calendar Year].[CY 2002]
, [Date].[Calendar Year].[CY 2003]} ON 0
FROM [Adventure Works]