如何创建全年计算的度量 mdx?

How to create a full year calculated measure mdx?

您好 MDX 和 SSAS 人员,

我想知道如何创建一个时间计算度量来总结 selected period/month 在本例中的全年总价值预算。因此,如果我从我的时间层次结构中 select 202004,它应该是 2020 年的总预算,如果我 select 201904,它应该是 2019 年的总预算。

在下图中,我使用以下 mdx 代码创建了 [YTD Budget]:

Aggregate(periodstodate([Time].[Year-Month-Day].[Year],[Time].[Year-Month-Day].currentmember), 
[Measures].[Budget Amount])

现在我想创建[全年预算],但还没有找到解决方案(新手 mdx 用户)。有人对此有解决方案吗?

此致, 红宝石

以下是 Adventure Works 上的示例:

with member Measures.YearName 
AS (ANCESTOR([Date].[Calendar].Currentmember, [Date].[Calendar].[Calendar Year])).Name

member Measures.FullYear 
AS SUM(ANCESTOR([Date].[Calendar].Currentmember, [Date].[Calendar].[Calendar Year]), [Measures].[Internet Sales Amount])

select {[Measures].[Internet Sales Amount], Measures.FullYear, Measures.YearName } on 0,
{[Date].[Calendar].[Calendar Quarter].&[2012]&[1],
[Date].[Calendar].[Calendar Quarter].&[2012]&[2],
[Date].[Calendar].[Calendar Quarter].&[2012]&[3],
[Date].[Calendar].[Calendar Quarter].&[2012]&[4],
[Date].[Calendar].[Calendar Quarter].&[2013]&[1],
[Date].[Calendar].[Calendar Quarter].&[2013]&[2],
[Date].[Calendar].[Calendar Quarter].&[2013]&[3],
[Date].[Calendar].[Calendar Quarter].&[2013]&[4]
} on 1
from [Adventure Works]

所以在你的情况下,成员定义应该是:

   with member Measures.FullYear 
    AS SUM(ANCESTOR([Time].[Year-Month-Day].Currentmember, [Time].[Year-Month-Day].[Year]), [Measures].[Budget Amount])