Calculated Measure Rollup -
08-03-2006
, 09:14 AM
I have a dimension named KPIS which is an account dimension. The
relevant fields are KPIID (id), KPI Type (defines account type: R -
LastNonEmpty, P - Percentage, N - sum), and KPI Group. The hierarchy
here is KPI Group --> KPIS.
The Measures are ValueN, which comes from a KPIValues fact table, and
WarningN and TargetN which come from another fact table (KPITarget).
The calculated measure is defined as below.
The individual KPIS (by KPIID) are calculated properly based upon the
account type. So, If I choose one of the dimensions I have across time,
assets, etc, the values / warnings / targets are calculating properly.
However, when I apply the [NormalizedValue] calculated measure below,
it works for each individual KPIID correctly, but will not give me the
correct total when rolling up for the group. What I want, is to give an
average of these values. So, if I have the following, I should get 1.13
as an average of the NormalizedValues, which I am not.
How do I change the logic below to average the NormalizedValue(s)?
KPIID KPITYPE Value Target Warning NormalizedValue
1 R 0 0 1 .85
2 N 0 2.96 3.6 1.31
3 N 0 0.99 1.24 1.24
========
1.13
IIF ( ISEMPTY([Measures].[WarningN]) OR ISEMPTY([Measures].[ValueN]) OR
ISEMPTY([Measures].[TargetN])
,
NULL,
Case
When [Measures].[WarningN] = [Measures].[ValueN] then .75
When [Measures].[WarningN] < [Measures].[TargetN] then
case when [Measures].[ValueN] > [Measures].[WarningN]
then (.75 + (( [Measures].[ValueN] - [Measures].[WarningN]) /
(([Measures].[TargetN] - [Measures].[WarningN])*10)))
else (.75 - (( [Measures].[WarningN] - [Measures].[ValueN]) /
(([Measures].[TargetN] - [Measures].[WarningN])*10)))
end
else
case when [Measures].[ValueN] > [Measures].[WarningN]
then (.75 - (( [Measures].[ValueN] - [Measures].[WarningN] )
/ (([Measures].[WarningN] - [Measures].[TargetN])*10)))
else (.75 + (( [Measures].[WarningN] - [Measures].[ValueN] )
/ (([Measures].[WarningN] - [Measures].[TargetN])*10)))
end
end) |