Union

Returns a set generated by the union of two sets, optionally retaining duplicate members or sorting members.

Syntax

«Set» Union («Set1», «Set2»[, ALL | SORT])

The ALL flag can be used to retain duplicate members.

The SORT flag can be used in conjunction with the optimized Filter functions.

These notes apply:

  • You can use SORT if both sets are the result of an optimized Filter function.
  • The sorting result is only meaningful if both sets use the same base set.
  • The sorting is done in a way that the resulting tuples are in the same order as in the base set.
  • If one of the sets is not an optimized Filter result, the sorting is not guaranteed, and the results are appended.
  • If both sets are not optimized Filter results, the results are appended. The results are not sorted.
  • The SORT flag cannot be combined with the ALL flag.
  • The SORT flag is case insensitive.

Example

WITH
   SET [BaseSet] AS '{ [USA], [Canada], [Mexico] }' 
   SET [FilterSet1] AS 'FilterLT([BaseSet], 2000, ([Units]))' 
   SET [FilterSet2] AS 'FilterGT([BaseSet], 10000, ([Units]))' 
   SET [Union] AS 'Union([FilterSet1], [FilterSet2], SORT)'
SELECT [Union] ON ROWS, [Measures].Members ON COLUMNS
FROM TotSales