Friday, March 30, 2012

Problem with calculated member (AS2005)

Hi all,
I'm having some strange problems with a calculated member in AS2005.
My calculated_member definition is as follows:

([Measures].[measure_1]/[Measures].[measure_2])

Now, i have an mdx query that uses that member. Something like:

SELECT [Measures].[measure_1],[Measures].[measure_2],[Measures].[calculated_member] ON COLUMNS
blah blah on ROWS
FROM [mycube]
WHERE some date conditions

[Measures].[measure_1] value is 2285.4 (this number is correct, i verified it)
[Measures].[measure_2] value is 82.67 (this number is correct, i verified it)
[Measures].[calculated_member] value is 14805.03 (WRONG, should be 2285.4/82.67= 27.64!!!)

What's going on here? I don't get why calculated_member fails, when the measures it depends on are just fine. Could someone give me a hint.

PS: measure_1 and measure_2 are both calculated as well.
PS2: all measures have "MEASURES" as parent hierarchy.

Hi,

I think the problem is the SOLVE_ORDER. For example

your measure_1 Sum is added from a1 + a2 + a3 + a4 + ....
your measure_2 Sum is added from b1 + b2 + b3 + b4 + .....

Your "wrong" calculated member sum comes from a1/b1 + a2/b2 + a3/b3 + a4/b4 + .....

but you would like to build a sum like (a1 + a2 + a3 + a4 + ....) / (b1 + b2 + b3 + b4 + .....)

This you could handle with the SOLVE_ORDER directive

MEMBER [Measures].[calculated_member] As ([Measures].[measure_1]/[Measures].[measure_2]) SOLVE_ORDER=1 .....

Hans

|||Thanks for the advice. Unfortunately in calculations tab of sql2005, the script expression doesn't allow SOLVE_ORDER clause (my calculated member was not defined in the MDX query, but IN THE CUBE). By manually changing this particular calculation to the bottom of the list (in the "script organizer" pane to the left of the screen) the problem was gone, so I guess it has to do with the order in which you define calculated members in a cube, isn't it?|||Order matters, but you can always manually overwrite SOLVE_ORDER if you need to. Just switch to the Script View from the Forms View and add ", SOLVE_ORDER=..." at the end of CREATE MEMBER statement.

No comments:

Post a Comment