Union

Returns the union of two input sets, optionally retaining duplicates.

Syntax

Union ( set1, set2 [,ALL] )
ParameterDescription

set1

A set to join with set2.

set2

A set to join with set1.

ALL

If the optional ALL keyword is used, duplicates are retained.

Notes

Duplicates are eliminated by default from the tail of the set. The optional ALL keyword retains duplicates. The two input sets must have identical dimension signatures. For example, if set1 consists of dimensions Product and Market, in that order, then set2 should also consist of Product followed by Market.

Example

Example 1

The expression

Union( Siblings([Old Fashioned]), {[Sarsaparilla], [Birch Beer]}) 

returns the set

{ [Old Fashioned], [Diet Root Beer], [Sarsaparilla], [Birch Beer] }

Example 2

The expression

Union( Siblings([Old Fashioned]), {[Sarsaparilla], [Birch Beer]}, ALL)

returns the set

{ [Old Fashioned], [Diet Root Beer], [Sarsaparilla], [Birch Beer],
      [Sarsaparilla], [Birch Beer] }

Example 3

The following query

SELECT
CrossJoin (
         Union (
            Siblings ([Old Fashioned]),
            {([Root Beer]), ([Cream Soda])}
         ),
         {(Budget), ([Variance])}
      )
ON COLUMNS
from Sample.Basic

returns the grid

Old FashionedDiet Root BeerSarsaparillaBirch BeerRoot BeerCream Soda
BudgetVarianceBudgetVarianceBudgetVarianceBudgetVarianceBudgetVarianceBudgetVariance
11640-443914730-27055050-4144530-43835950-799629360-3561