Returns the union of two input sets, optionally retaining duplicates.
Syntax
Union ( set1, set2 [,ALL] )
| Parameter | Description |
|---|---|
A set to join with 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
The expression
Union( Siblings([Old Fashioned]), {[Sarsaparilla], [Birch Beer]}) returns the set
{ [Old Fashioned], [Diet Root Beer], [Sarsaparilla], [Birch Beer] }The expression
Union( Siblings([Old Fashioned]), {[Sarsaparilla], [Birch Beer]}, ALL)returns the set
{ [Old Fashioned], [Diet Root Beer], [Sarsaparilla], [Birch Beer],
[Sarsaparilla], [Birch Beer] }The following query
SELECT
CrossJoin (
Union (
Siblings ([Old Fashioned]),
{([Root Beer]), ([Cream Soda])}
),
{(Budget), ([Variance])}
)
ON COLUMNS
from Sample.Basicreturns the grid
| Old Fashioned | Diet Root Beer | Sarsaparilla | Birch Beer | Root Beer | Cream Soda | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Budget | Variance | Budget | Variance | Budget | Variance | Budget | Variance | Budget | Variance | Budget | Variance |
| 11640 | -4439 | 14730 | -2705 | 5050 | -414 | 4530 | -438 | 35950 | -7996 | 29360 | -3561 |