1
WITH MEMBER [Measures].[Country Count]
AS
Count(existing [Customer].[Customer Geography].[Country])

MEMBER [Customer].[Customer Geography].ClassA AS
SUM(filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 3000))

MEMBER [Customer].[Customer Geography].ClassB AS
SUM(filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 1500))


MEMBER [Customer].[Customer Geography].ClassC AS
SUM(filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 0))

SET My_Custom_Set AS
{[Customer].[Customer Geography].ClassA, [Customer].[Customer Geography].ClassB,[Customer].[Customer Geography].ClassC}

SELECT  {[Measures].[Internet Order Count], [Measures].[Internet Sales Amount], [Measures].[Country Count]} ON COLUMNS,
My_Custom_Set ON ROWS
FROM 
[Adventure Works]

结果:

结果

在上面的查询中,如何获得有多少国家贡献了 A 类、B 类、C 类,这里对于任何类,最大国家计数 6 显示在度量“国家计数”中?

为什么 Here existing不提供当前班级的国家数量?

4

1 回答 1

2

这不起作用,因为您在同一层次结构中工作:[Customer].[Customer Geography].ClassA是该层次结构的新成员,FIlter结果不包含在其中,因此EXISTING不起作用。

以下查询有效(注意counts 在基本集上):

WITH 
SET ClassA AS
filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 3000)

SET ClassB AS
filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 1500)

SET ClassC AS
filter([Customer].[Customer Geography].[Country],[Measures].[Internet Order Count] > 0)

MEMBER [Customer].[Customer Geography].ClassA AS
SUM(ClassA)

MEMBER [Customer].[Customer Geography].ClassB AS
SUM(ClassB)

MEMBER [Customer].[Customer Geography].ClassC AS
SUM(ClassC)

MEMBER [Measures].[Country Count]
AS
CASE 
    WHEN [Customer].[Customer Geography].CurrentMember IS [Customer].[Customer Geography].ClassA THEN
         ClassA.Count
    WHEN [Customer].[Customer Geography].CurrentMember IS [Customer].[Customer Geography].ClassB THEN
         ClassB.Count
    WHEN [Customer].[Customer Geography].CurrentMember IS [Customer].[Customer Geography].ClassC THEN
         ClassC.Count
    WHEN [Customer].[Customer Geography].CurrentMember IS [Customer].[Customer Geography].[All Customers] THEN
         [Customer].[Customer Geography].[Country].Count
    ELSE
         1
END


SET My_Custom_Set AS
{[Customer].[Customer Geography].ClassA, [Customer].[Customer Geography].ClassB,[Customer].[Customer Geography].ClassC}

SELECT  {[Measures].[Internet Order Count], [Measures].[Internet Sales Amount], [Measures].[Country Count]} ON COLUMNS,
My_Custom_Set ON ROWS
FROM 
[Adventure Works]
于 2013-10-23T17:04:52.073 回答