我有一个包含2个层次结构的1维数据:公历,计划日历。 [格里高利年] - [格里高利月] - [格里高利日] [计划年度] - [计划月] - [计划日] 我有2个MDX措施:
[Planning Stock] = Sum(PeriodsToDate([Data].[Planning Calendar].[(All)]), [amount])
[Gregorian Stock] = Sum(PeriodsToDate([Data].[Gregorian Calendar].[(All)]), [amount])
如何创建一个能够识别层次结构的度量? 我写了类似的东西,但它不起作用:(
iif(([Data].currentmember.level is [Data].[Planning Calendar].[(All)]),
(Sum(PeriodsToDate([Data].[Planning Calendar].[(All)]), [amount])),
(Sum(PeriodsToDate([Data].[Gregorian Calendar].[(All)]), [amount]))
)
你有什么想法吗?
答案 0 :(得分:0)
您可以使用level.hierarchy执行此操作。看一个例子。
with member
measures.t
as
axis(1).item(0).hierarchy.name
select
{
[Measures].[Internet Sales Amount],measures.t
}
on columns,
{
[Date].[Fiscal].[Month].&[2014]&[7].children
--[Date].[Calendar].[Month].&[2013]&[6].children
}
on rows
from [Adventure Works]
结果
让我们更改层次结构
with member
measures.t
as
axis(1).item(0).hierarchy.name
select
{
[Measures].[Internet Sales Amount],measures.t
}
on columns,
{
--[Date].[Fiscal].[Month].&[2014]&[7].children
[Date].[Calendar].[Month].&[2013]&[6].children
}
on rows
from [Adventure Works]
结果