使用 MDX 在 SSAS 中创建计算成员

Create calculated member in SSAS using MDX

致所有 MDX 专家, 我有一个在 SSAS 中创建成员的场景。有一个事实 table 有每天的数据快照。

2018Q1 是从 12 月到 2 月。要求是创建一个计算成员,如果在 2018 年第一季度切片,它将给出 2018 年第一季度最后一天快照的不同价值计数,即 20180228 的不同价值计数( A1 2018 的最后一天)和类似地,这应该在月份的最后一天工作,在月份级别切片,周和年反之亦然。 我在日期维度中有日历层次结构。

最终结果集应该是这样的:

我已经创建了度量值的不同计数,但这仅适用于日期级别。

请帮忙

您需要使用带有 Self 标志的 descendants 函数。看看下面的示例

with member measures.t 
as 
(Descendants  ([Date].[Calendar].currentmember,[Date].[Calendar].[Date],SELF).item(Descendants ([Date].[Calendar].currentmember,[Date].[Calendar].[Date],SELF).count-1).item(0)
,[Measures].[Internet Sales Amount])

member measures.t1 
as 
Descendants  ([Date].[Calendar].currentmember,[Date].[Calendar].[Date],SELF).item(Descendants ([Date].[Calendar].currentmember,[Date].[Calendar].[Date],SELF).count-1).item(0).name

SELECT {measures.t ,measures.t1}
ON 0 ,
[Date].[Calendar].[Calendar Year].&[2013]
on 1 
FROM [Adventure Works]