Hi Jamie,
Quote:
If I understand your problem correctly (unlikely knowing me), a derivation
of the following should solve your problem:
Thanks for the quick reply, Jamie. I should have included examples of what I
|
meant, my descriptions tend to be a little bit rushed and chaotic. So here
follow examples for the problem and the (possible) solutions:
Assume the following data (way simplified):
[ApproximateCost] [RealCost]
[Store].[USA] 12000 14000
[Store].[Europe] null 300000
[Store].[Asia] 2000 3000
now assume all members have sum as their aggregation function and compute
the following query:
WITH MEMBER [Measures].[ApproximationQuality] AS
'[Measures].[RealCost] / [Measures].[ApproximateCost]'
select {[Measures].[ApproximationQuality]} on AXIS[0]
{[Store].[All Stores]} on AXIS[1]
from CostData
what you get will be ([Store].[All Stores],[Measures].[RealCost]) /
([Store].[All Stores],[Measures].[ApproximateCost])
which amounts to
(14000+300000+3000) / (12000+2000) = 22.64
Now that is not what one would expect from the measure ApproximationQuality.
The "right" way (at least what I intended) is to perform the calculation
ignoring [Store].[Europe], since the [ApproximateCost] is missing there and
instead compute:
(14000+3000)/(12000+2000) = 1.21
Your proposal
Quote:
WITH MEMBER [Measures].[ApproximationQuality] AS
'IIF([Measures].[ApproximateCost] IS NULL OR
IsEmpty([Measures].[ApproximateCost]), 0, [Measures].[RealCost] /
[Measures].[ApproximateCost])' |
does not work either, as a simple null check will not help here as neither
([Store].[All Stores],[Measures].[RealCost]) nor ([Store].[All
Stores],[Measures].[ApproximateCost]) are null.
My question is whether someone has encountered that problem and how they
dealt with it and what people think about the ways I came up with / have see
n for solving that problem.
Here are the missing examples to my proposed solutions, for a more abstract
description and my perceived pros and cons see my original post...
1) Using a filter to do the same query like
WITH MEMBER [Measures].[ApproximationQuality] AS
'sum(crossjoin({filter([Store].currentmember.children,
([Store].currentmember, [Measures].[RealCost] is not null) and
([Store].currentmember, [Measures].[ApproximateCost] is not
null)},{[Measures].[RealCost]})
/
sum(crossjoin({filter([Store].currentmember.children,
([Store].currentmember, [Measures].[RealCost] is not null) and
([Store].currentmember, [Measures].[ApproximateCost] is not
null)},{[Measures].[ApproximateCost]})'
select {[Measures].[ApproximationQuality]} on AXIS[0]
{[Store].[All Stores]} on AXIS[1]
from CostData
I know that the filter() statements will need some work to be really useful
as you'd probably want to get down to leave level, but I think this simple
version is enough to show the idea behind this way of solving the problem.
2) Introduce a dimension [DataQuality] ([DataQuality].[Good],
[DataQualityBad]) such that all fact table entries which have both
[RealCost] and [ApproximateCost] filled out get [DataQuality].[Good] and all
other get [DataQuality].[Bad].
Assuming that dimension, the query would look like
WITH MEMBER [Measures].[ApproximationQuality] AS
'([DataQuality].[Good],[Measures].[RealCost]) /
([DataQuality].[Good],[Measures].[ApproximateCost])'
select {[Measures].[ApproximationQuality]} on AXIS[0]
{[Store].[All Stores]} on AXIS[1]
from CostData
3) Introduce two new measures [Measures].[RealCostAQ] and
[Measures].[AproximateCostAQ]. These would get filled in the ETL scripts
like this:
RealCostAQ = case when RealCost is not null and
ApproximateCost is not null RealCost else null end
ApproximateCostAQ = case when RealCost is not null and
ApproximateCost is not null ApproximateCost else null end
This way our original query could be rewritten to
WITH MEMBER [Measures].[ApproximationQuality] AS
'[Measures].[RealCostAQ] / [Measures].[ApproximateCostAQ]'
select {[Measures].[ApproximationQuality]} on AXIS[0]
{[Store].[All Stores]} on AXIS[1]
from CostData
and produce the desired result.
4) Define a new cube and insert only records into its fact table, that have
RealCost and ApproximateCost non null.
Hope that helps to clarify my first post, please tell me if anything is
unclear, missing or wrong.
On a final note, thanks for reading all the way, these are rather long
posts, but I feel that coming up with some potential solutions is a better
base to start a discussion from (or rule out all at once

.
PS that post made me wish newsreaders had syntax highlightning...
regards
Stefan Farthofer