Distinct(MDX)

计算指定集合,移除重复元组,返回所得集合。

Syntax

  
Distinct(Set_Expression)  

Arguments

Set_Expression
一个有效的多维表达式(MDX)表达式,返回集合。

Remarks

如果 Distinct 函数在指定集合中发现重复元组,函数只保留重复元组的第一个实例,同时保持该集合的顺序不变。

示例

以下示例查询展示了如何使用不同函数(Distinct function)与命名集合,以及如何与计数函数(Count)结合使用,以查找集合中不同元组的数量:

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]