Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.88 KB

intersect-mdx.md

File metadata and controls

65 lines (49 loc) · 1.88 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic ms.custom
Intersect (MDX)
Intersect (MDX)
kfollis
kfollis
kfollis
02/17/2022
sql
analysis-services
reference
mdx

Intersect (MDX)

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

Syntax

  
Intersect(Set_Expression1 , Set_Expression2 [ , ALL ] )  

Arguments

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

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

Remarks

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. The two sets specified must have the same dimensionality.

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]  

See Also

MDX Function Reference (MDX)