I have a complex MDX calculated measure question. I have two measures and a Hour-Minute hierarchy. At the hourly level, MeasureA rolls up to the Max value of the underlying minute values. MeasureB should roll up to the corresponding value of the Max from MeasureA. In the example below, 8 is the Max of MeasureA. So MeasureB should roll up to 2 at the hourly level. I am having trouble with the MeasureB calculation. Any ideas how I can do this in an MDX calculated measure?
MeasureA Measure B
Hour 8 2
Minute1 2 3
Minute2 1 2
Minute3 5 1
Minute4 6 3
Minute5 8 2
In addition to the above.... I have two hierarchies "Year-Month-Day" and "Hour-Minute". This works perfectly for the Hour-Minute hierachy. However, when I also want the same logic to roll up from Hour to Day even though they are in separate hierarchies. I have the code below for the working hour/minute keys and the non-working day keys. Do you see anything that I am doing wrong.
Measure A = "Avg Used Resources" and Measure B = "Total Resources"
// Total Resources Calculation
---Initializing keys
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Used Resources Key Minutes]
AS null,
VISIBLE = 1, ASSOCIATED_MEASURE_GROUP = 'NSS Resource Utilization';
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Used Resources Key Hours]
AS null,
VISIBLE = 1, ASSOCIATED_MEASURE_GROUP = 'NSS Resource Utilization';
CREATE MEMBER CURRENTCUBE.[Measures].[Avg Used Resources Key Days]
AS null,
VISIBLE = 1, ASSOCIATED_MEASURE_GROUP = 'NSS Resource Utilization';
---
-- Minute Key
SCOPE ([Time].[Hour-Minute].[Time Name],[Measures].[Avg Used Resources Key Minutes]);
THIS = IIF(([Time].[Hour-Minute].CurrentMember,[Measures].[Avg Used Resources])
= ([Time].[Hour-Minute].CurrentMember.Parent,[Measures]. [Avg Used Resources])
, [Time].[Hour-Minute].CurrentMember.Member_Key, null);
END SCOPE;
-- Hour Key
SCOPE ([Measures].[Avg Used Resources Key Hours]);
THIS = MAX([Time].[Hour-Minute].CurrentMember.Children,[Measures].[Avg Used Resources Key Minutes]);
END SCOPE;
-- Day Key
SCOPE ([Measures].[Avg Used Resources Key Days]);
THIS = IIF(([Time].[Hour-Minute].CurrentMember,[Measures].[Avg Used Resources])
= ([Time].[Hour-Minute].CurrentMember.Parent, [Measures].[Avg Used Resources])
, [Time].[Hour-Minute].CurrentMember.Member_Key, null);
END SCOPE;
-- Hour Value
SCOPE ([Time].[Hour-Minute].[Hour 24],[Measures].[Total Resources]);
THIS = (StrToMember("[Time].[Hour-Minute].[Time Name].&["+CStr([Measures]. [Avg Used Resources Key Hours])+"]")
,[Measures].[Total Resources]);
END SCOPE;
--Date Value
SCOPE ([Time].[Hour-Minute].[ALL],[Measures].[Total Resources]);
THIS = (StrToMember("[Time].[Hour-Minute].[Hour 24].&["+CStr([Measures].[Avg Used Resources Key Days])+"]")
,[Measures].[Total Resources]);
END SCOPE;