0
votes

I have 1 dimension Data with 2 hierarchies: Gregorian Calendar, Planning Calendar. [Gregorian Year] - [Gregorian Month] - [Gregorian Day] [Planning Year] - [Planning Month] - [Planning Day] I have 2 MDX measures:

[Planning Stock] = Sum(PeriodsToDate([Data].[Planning Calendar].[(All)]), [amount])

[Gregorian Stock] = Sum(PeriodsToDate([Data].[Gregorian Calendar].[(All)]), [amount])

How to create one measure that will recognize the hierarchy? I wrote something like that, but it does not work :(

iif(([Data].currentmember.level is [Data].[Planning Calendar].[(All)]),
(Sum(PeriodsToDate([Data].[Planning Calendar].[(All)]), [amount])),
(Sum(PeriodsToDate([Data].[Gregorian Calendar].[(All)]), [amount]))
)

Do you have any ideas?

1

1 Answers

0
votes

You can do this using the level.hierarchy. Take a look at the example.

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]

Result

enter image description here

Lets change the 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]

Result

enter image description here