从我的多维数据集中,我试图得到所有非空[ID].[FullID]的不同计数,但是[Underlying]对其进行了总结。
例如,我知道在这个特定的WHERE片上有两个[Underlying].[Underlying1] ID,我可以通过运行下面的MDX查询来看到这一点,这清楚地给出了每个[Underlying].[Underlying1]的一行(但是零计数?):
结果:
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点,但我想不出来.
发布于 2018-11-29 20:53:50
您将得到24,因为您正在计算ID.FullID.Children中的成员数。我所理解的是,对于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]
)这里是一个你想在冒险工作中做什么的例子。我试图统计所有的促销活动,这是基于互联网销售数据的产品。
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]//Base查询以了解所计算的内容
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]https://stackoverflow.com/questions/53542371
复制相似问题