0

从我的多维数据集中,我试图获得所有非空[ID].[FullID]但由[Underlying].

我知道,例如,[Underlying].[Underlying1]在这个特定的 WHERE 切片上有两个 ID,我可以通过运行下面的 MDX 查询来看到这一点,这清楚地为每个提供了一行(但计数为零?):

结果:

Underlying  | FullID | CountOf
------------------------------
Underlying1 | ID1    | 0
Underlying1 | ID2    | 0
...

代码:

WITH 
    MEMBER CountOf AS
    DistinctCount([ID].[FullID].Children)
SELECT
    NON EMPTY {[Underlying].Children * [ID].[FullID].Children
    } ON ROWS,
    NON EMPTY {CountOf
    } ON COLUMNS
FROM [MyCube]
WHERE ([Time].&[2018-11-27T00:00:00],
       [Factor].[FactorName].[FACTOR1],
       [Factor].[FactorType].[FACTORTYPE1]
       [Location].[Location1]
       )

但是,当我删除时,* [ID].[FullID].Children我没有得到想要的东西:

我想要的是:

Underlying  | CountOf
---------------------
Underlying1 | 2
...

我得到什么:

Underlying  | CountOf
---------------------
Underlying1 | 24
...

显然这里还有其他事情要给我一个 24 计数,但我无法弄清楚......

4

1 回答 1

0

你得到 24,因为你衡量的是计算 [ID].[FullID].Children 中的成员。我的理解是,您想计算 [ID].[FullID] 的数量,这些 [ID].[FullID] 对 [Underlying].Children 有事实价值。所以你的代码应该是这样的

WITH 
MEMBER CountOf AS
Count(
nonempty(([Underlying].currentmember,[ID].[FullID].Children),
[Measures].[ConnectingMeasure])
)
SELECT NON EMPTY {[Underlying].Children } ON ROWS,
NON EMPTY {CountOf} ON COLUMNS
FROM [MyCube]
WHERE ([Time].&[2018-11-27T00:00:00],[Factor].[FactorName].[FACTOR1],
[Factor].[FactorType].[FACTORTYPE1],[Location].[Location1]
)

以下是您想在 Adventureworks 中执行的操作的示例。我正在尝试计算基于互联网销售数据的产品的所有促销活动。

WITH 
MEMBER CountOf AS
count(nonempty( ([Product].[Product].currentmember, [Promotion].[Promotion].children) ,[Measures].[Internet Sales Amount]))
SELECT
NON EMPTY {CountOf} ON COLUMNS,
NON EMPTY {
([Product].[Product].Children )
} ON ROWS
FROM [Adventure Works]

//基本查询以了解计数的内容

WITH 
MEMBER CountOf AS
Count(nonempty( ([Product].[Product].currentmember, [Promotion].[Promotion].children) ,[Measures].[Internet Sales Amount]))
SELECT
NON EMPTY [Measures].[Internet Sales Amount] ON COLUMNS,
NON EMPTY {
([Product].[Product].Children,[Promotion].[Promotion].children )
} ON ROWS
FROM [Adventure Works]
于 2018-11-29T20:53:50.080 回答