0
votes

I try to add a calculated member to a cube,

Currently in my report, I have something like this

dimension value
a         5
b         10

I try to add one calculated member x (= a/b)

dimension value
a         5
b         10
x         0.5

This works in management studio:

    with member [dimension].[hierarchy].[x] as
    ( [Measures].[Value], [dimension].[hierarchy].[a])/
    ([Measures].[Value], [dimension].[hierarchy].[b])

    select [Measures].[Value]
    on 0
    ,
    {
    (
    [dimension].[hierarchy].[a]
    ,[dimension].[hierarchy].[b]
    ,[dimension].[hierarchy].[x])
    } on 1
    from [cube]
    where { [Date].[Date].&[20140821]}

But in the cube - calculated member, I tried assign the calculated member to [dimension].[hierarchy], in browser, I can see the x under [dimension].[hierarchy] together with 'All' member. But when I right click it, there is only option to add it to subcube, but I want it to be added to row area.

I know I can create calculated measure instead of calculate dimension, so it will be something like this:

dimension value x
a         5     0.5
b         10    0.5

but it's confusing for users.

I am novice, so is this doable (calculated dimension member)? and how?

1
what goal are you trying to accomplish with this? Typically the result of your division would be a calculated measure, and the values could change based upon filters. You are trying to add it as a dimension attribute member. Why?mmarie
@mmairie I am trying to added the calculated member as a extra row after a and b as showed above. This is mainly for reporting.thotwielder
Untested, what if you try this: with member [dimension].[hierarchy].[x] as SUM([dimension].[hierarchy].[a],[Measures].[Value])/ SUM([dimension].[hierarchy].[b],[Measures].[Value])Tab Alleman

1 Answers

0
votes

A few years late to the party here!

However this is a common requirement when processing financial data. Typically for a P&L report there will be a set of metrics which need to be added to the same dimension table so that the rows come out in the correct order on, especially if using SSRS. Metrics typically are ratios such as Average Weekly Fee.

You are wanting to calculate a ratio. A very powerful way of doing this is to use the SCOPE statement in the SASS cube calculations. The Scope statement can effectively inject a calculated value against a dimension value that will automatically recalculate depending on the time dimension in any MDX queries you subsequently write.

For example the value of a/b for a given month will differ from that for a given quarter. X of course needs to exist in the dimension even if it has no value initially. Our scope statement would look something like this:

SCOPE ([Measures].[Value], {[dimension].[hierarchy].[x]});
   This = IIF([dimension].[hierarchy].[b] = 0, null,
   [dimension].[hierarchy].[a]/[dimension].[hierarchy].[b];
END SCOPE;

Whilst [Measure].[Value] is defined for the whole dimension based on an underlying related fact table, we are only altering the measure value associated with x and also catering for the possibility that b could be zero.