共用方式為


DistinctCount (MDX)

傳回集合中相異 (Distinct) Tuple、非空白 Turple 的數目。

語法

DistinctCount(Set_Expression)

引數

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

備註

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].&[1],[Measures].[Internet Sales Amount] )}

//Returns the value 3 because Internet Sales Amount is null

//for the UK on the date specified

MEMBER MEASURES.SETDISTINCTCOUNT AS

DISTINCTCOUNT(MySet)

SELECT {MEASURES.SETDISTINCTCOUNT} ON 0

FROM [Adventure Works]