Before I carry on with my chalk talk series, I have to own up to something: I didn’t actually want to present on the topic of KPIs, and when I found out that I was going to have to talk on the subject I fired off a few emails to people who spend more time with KPIs than I do to ask them if they could suggest some interesting things to talk about. One of these people was Nick Barclay, co-author of ‘The Rational Guide to Business Scorecard Manager 2005’ (which I shall be reviewing very soon – it’s a good book), and he pointed out that while all the examples of KPIs he’d seen hard-coded goals and thresholds into the MDX code this was not a good thing – users want to change their values all the time and ideally you’d want to be able to let them do this themselves. Why not store these values in a measure group, allow users to change the values using writeback, and then use these values within the KPI definition somehow?
Actually modelling how the values should be stored in measure groups was very straightforward. In my demo I showed two fact tables, one for the Goals and one for the Thresholds, with one measure each. I also created a KPI dimension for both of them to allow multiple goals and thresholds for different KPIs to be stored in the same measure group; for the Goal measure group I added the Date dimension at the granularity of Calendar Year (so there was a column in the fact table containing year names) and for the Threshold fact table I also created a Threshold dimension. This Threshold dimension contained one member for each threshold to be used: Very Bad, Quite Bad, OK, Quite Good and Very Good; there was also a numeric column containing the values -1, -0.5, 0, 0.5 and 1 which represented the numeric values each threshold gets normalised to and which I assigned to the ValueColumn property of my sole attribute when I built the dimension.
One this was done and the measure groups were added to the Adventure Works cube, I showed some ways to allocate the Goal values down from the Year granularity at which they were stored. Here’s the scoped assignment for the simple allocation which simply splits the values equally by the number of time periods in the year, so for example each month shows 1/12 of the year total:
SCOPE([Measures].[Goal]);
SCOPE([Date].[Calendar Semester].[Calendar Semester].MEMBERS, [Date].[Date].MEMBERS);
THIS=[Measures].[Goal]/
COUNT(
DESCENDANTS(
ANCESTOR([Date].[Calendar].CURRENTMEMBER,[Date].[Calendar].[Calendar Year])
, [Date].[Calendar].CURRENTMEMBER.LEVEL
)
);
END SCOPE;
END SCOPE;
Here’s the code for doing the weighted allocation by the previous year’s Internet Sales Amount measure values:
SCOPE([Measures].[Goal]);
SCOPE([Date].[Calendar Semester].[Calendar Semester].MEMBERS, [Date].[Date].MEMBERS);
THIS=[Measures].[Goal]
*
(
(PARALLELPERIOD([Date].[Calendar].[Calendar Year],1,[Date].[Calendar].CURRENTMEMBER), [Measures].[Internet Sales Amount])
/
(ANCESTOR([Date].[Calendar].CURRENTMEMBER,[Date].[Calendar].[Calendar Year]).PREVMEMBER, [Measures].[Internet Sales Amount])
);
END SCOPE;
END SCOPE;
A few things to note here:
- In both cases, because I’ve set IgnoreUnrelatedDimensions to false on the measure group, to get the year’s Goal measure value I can simply reference [Measures].[Goal] – the values for the year are copied down automatically to the attributes below the granularity attribute.
- Although normally when you assign a value to a regular measure with an additive aggregation function the assigned value gets aggregated up, when you assign to a regular measure below the granularity attribute of a dimension no aggregation happens, similar to what you get with a calculated measure.
- The assignment SCOPE([Date].[Calendar Semester].[Calendar Semester].MEMBERS, [Date].[Date].MEMBERS) means ‘scope on everything from the Date attribute (I’ve included the whole attribute here, All Member and the leaf level – everything on a dimension exists with either the All Member or the leaf members of the key attribute) up to and including the Calendar Semester attribute but no higher’.
Moving onto the thresholds, we need to find a way to apply the threshold values we’ve got in our measure group to the measure we’re interested in. Here’s a calculated member definition that does this:
CREATE MEMBER CurrentCube.[Measures].[Internet Sales To Goal Status] AS
TAIL(
{[Threshold].[Threshold].&[1],
FILTER(
[Threshold].[Threshold].&[2]:null
, ([Measures].[Threshold],[KPI].[KPI].&[1])
<
([Measures].[Internet Sales Amount]/[Measures].GOAL)
)}
,1).ITEM(0).MEMBERVALUE
;
What I’m doing here is creating a set that always contains the first member of the Threshold dimension, the ‘Very Bad’ member, and then filtering on the set that contains every other threshold to return the members for whom the threshold measure is less than the value of Internet Sales Amount. I then get the last member in that set, which represents the threshold with the highest value that is less than Internet Sales Amount, and use the MemberValue function to get the normalised value (the value between -1 and 1) that I assigned to that member.
This a great concept that you\’ve laid out here, although I\’m having a hard time fully grasping the Threshold piece of the solution. Do you happen to still have the code that you used for the demo that you could post?Thanks
Hmm, probably not, sorry. But feel free to ask questions…
I got question regarding IgnoreUnrelatedDimensions , Our cube got 2 measure group one with detailed data of daily granularity,other one is weekly aggregated measure group.2 date dimensions(BillingStart,EventStart) both are related to detailed measure group.Weekly Aggregate is not related to Billing Start Date Dimension.For all the measure group i have set IgnoreUnrelatedDimensions=false that way unrelated dimension issue resolved.
Now i want to create calculated measure in weekly aggregated measure group which will add both weekly measure and detailed measure lets say [Sales USD](from detailed ) + [Weekly Sales USD] (from weekly).
iif(isEmpty([Measures].[Weekly Sales USD]),null,[Measures].[Weekly Sales USD]+[Measures].[Sales USD]) my idea was if unrelated date dimension attribute is used in browser we can check with isempty and avoid showing value.But for related dimension also if there is not overlapping week data it wont add.
Could you please help to find solution.
I got question regarding IgnoreUnrelatedDimensions , Our cube got 2 measure group one with detailed data of daily granularity,other one is weekly aggregated measure group.2 date dimensions(BillingStart,EventStart) both are related to detailed measure group.Weekly Aggregate is not related to Billing Start Date Dimension.For all the measure group i have set IgnoreUnrelatedDimensions=false that way unrelated dimension issue resolved.
Now i want to create calculated measure in weekly aggregated measure group which will add both weekly measure and detailed measure lets say [Sales USD](from detailed ) + [Weekly Sales USD] (from weekly).
iif(isEmpty([Measures].[Weekly Sales USD]),null,[Measures].[Weekly Sales USD]+[Measures].[Sales USD]) my idea was if unrelated date dimension attribute is used in browser we can check with isempty and avoid showing value.But for related dimension also if there is not overlapping week data it wont add.
Could you please help to find solution.