Export (0) Print
Expand All
Expand Minimize

Intersect (MDX)

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


Intersect(Set_Expression1 , Set_Expression2 [ , ALL ] )

Set_Expression1

A valid Multidimensional Expressions (MDX) expression that returns a set.

Set_Expression2

A valid Multidimensional Expressions (MDX) expression that returns a set.

The Intersect function returns the intersection of two sets. By default, the function removes duplicates from both sets prior to intersecting the sets. The two sets specified must have the same dimensionality.

The optional ALL flag retains duplicates. If ALL is specified, the Intersect function intersects nonduplicated elements as usual, and also intersects each duplicate in the first set that has a matching duplicate in the second set.

Example

The following query returns the Years 2003 and 2004, the two members that appear in both the sets specified:

SELECT

INTERSECT(

{[Date].[Calendar Year].&[2001], [Date].[Calendar Year].&[2002],[Date].[Calendar Year].&[2003]}

, {[Date].[Calendar Year].&[2002],[Date].[Calendar Year].&[2003], [Date].[Calendar Year].&[2004]})

ON 0

FROM

[Adventure Works]

The following query fails because the two sets specified contain members from different hierarchies:

SELECT

INTERSECT(

{[Date].[Calendar Year].&[2001]}

, {[Customer].[City].&[Abingdon]&[ENG]})

ON 0

FROM

[Adventure Works]

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft