DistinctCount(MDX)

返回集合中不同且非空的元组数量。

Syntax

  
DistinctCount(Set_Expression)  

Arguments

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

Remarks

DistinctCount函数等价Count(Distinct(Set_Expression), EXCLUDEEMPTY)于。

示例

以下查询展示了如何使用 DistinctCount 函数:

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]}  
* 
{([Date].[Calendar].[Date].&[20010701],[Measures].[Internet Sales Amount] )}   
MEMBER MEASURES.SETDISTINCTCOUNT AS  
DISTINCTCOUNT(MySet)  
SELECT {MEASURES.SETDISTINCTCOUNT} ON 0 
FROM [Adventure Works] 

DistinctCount函数返回集合中不同数量的项目;在这个例子中,可选的第二个参数用于排除给定元组没有取值的项。 在这种情况下,第一个参数中有四个不同的项目,但函数返回了三个,因为只有澳大利亚、加拿大和法国拥有2001年7月1日的互联网销售金额数据。