我正在尝试从多维数据集中获取所有非空[ID].[FullID]
的不同计数,但以[Underlying]
进行汇总。
我知道,例如,在此特定WHERE片上有[Underlying].[Underlying1]
的两个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个数字,但我无法弄清楚...
答案 0 :(得分:0)
您将获得24,因为您测量的是对[ID]。[FullID] .Children中的成员进行计数。我了解的是,您想计算[Underlying] .Children对他们有实际价值的[ID]。[FullID]的数量。所以您的代码应该像这样
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]
//基本查询以了解计数内容
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]