Share via


Distinct (MDX)

評估指定的集合、從集合中移除重複的 Tuple,並傳回產生的集合。

語法

  
Distinct(Set_Expression)  

引數

Set_Expression
傳回集合的有效多維度運算式 (MDX) 運算式。

備註

如果 Distinct 函式在指定的集合中找到重複的 Tuple,則函式只會保留重複 Tuple 的第一個實例,同時保留集合的順序保持不變。

範例

下列範例查詢示範如何搭配具名集合使用 Distinct 函式,以及如何搭配 Count 函式來尋找集合中的相異 Tuple 數目:

WITH SET MySet AS

{[Customer].[Customer Geography].[Country].&[Australia],[Customer].[Customer Geography].[Country].&[Australia],

[Customer].[Customer Geography].[Country].&[Canada],[Customer].[Customer Geography].[Country].&[France],

[Customer].[Customer Geography].[Country].&[United Kingdom],[Customer].[Customer Geography].[Country].&[United Kingdom]}

MEMBER MEASURES.SETCOUNT AS

COUNT(MySet)

MEMBER MEASURES.SETDISTINCTCOUNT AS

COUNT(DISTINCT(MySet))

SELECT {MEASURES.SETCOUNT, MEASURES.SETDISTINCTCOUNT} ON 0,

DISTINCT(MySet) ON 1

FROM [Adventure Works]

另請參閱

MDX 函數參考 (MDX)