我在尝试在SSAS多维数据集中创建MDX计算成员时遇到问题,该成员将根据日历层次结构中的日期显示前12个月(当前月份除外)的聚合。
我找到this post但是,因为在我的情况下,基本度量是一个DistinctCount聚合,YTD()
函数不能通过添加Aggregate()
来工作 - 它总是显示{{1}通过添加NULL
,它会显示Sum()
,这是不正确的。
答案 0 :(得分:0)
这是针对DISTINCT COUNT指标并且功能正常 - 虽然它可以理解为缓慢:
WITH
MEMBER [Measures].[ytdCalc] AS
Aggregate
(
Head
(
Descendants
(
Ancestor
(
[Date].[Date - Calendar Month].CurrentMember
,[Date].[Date - Calendar Month].[Calendar Year]
).Item(0).Item(0)
,[Date].[Date - Calendar Month].[Calendar Month]
)
).Item(0).Item(0)
:
[Date].[Date - Calendar Month].CurrentMember
,[Measures].[Num People]
)
SELECT
{
[Measures].[ytdCalc]
,[Measures].[Num People]
} ON 0
,[Date].[Date - Calendar Month].[Calendar Month] ON 1
FROM [aCube];
YTD
对我来说很好。我这样用它:
WITH
MEMBER [Measures].[ytdCalc] AS
Aggregate
(
YTD([Date].[Date - Calendar Month].CurrentMember)
,[Measures].[Num People]
)
SELECT
{
[Measures].[ytdCalc]
,[Measures].[Num People]
} ON 0
,[Date].[Date - Calendar Month].[Calendar Month] ON 1
FROM [aCube];