Tuesday, March 27, 2012

Calculated Member

Hi

When looking at the template of the calculated member [Percentage of Total] it appears that I have to refer to the <<Target Hierarchy>>.
That means that I have to create a calculated member for every hierarchy.
Is there a way to create only one calculated member that refer to current hierarchy.


Thanks

Yes, this template assumes you want to see percentage of total relative to a single dimension. If you want to see different percentages of totals relative to different dimensions at the same time you'll need seperate calculated members. However, if you want to see percentage of total relative to multiple dimensions, you can additional dimensions to the formula as follows:

//

/*Calculates the ratio of a specific member's value to the value of all members.*/

CREATE MEMBER CURRENTCUBE.[MEASURES].[Percentage of Total]

AS Case

// Test to avoid division by zero.

When IsEmpty

(

[Measures].[<<Target Measure>>]

)

Then Null

Else ( [<<Target Dimension 1>>].[<<Target Hierarchy>>].CurrentMember,

[<<Target Dimension 2>>].[<<Target Hierarchy>>].CurrentMember,

...

[<<Target Dimension n>>].[<<Target Hierarchy>>].CurrentMember,

[Measures].[<<Target Measure>>] )

/

(

// The Root function returns the (All) value for the target dimension.

Root

(

[<<Target Dimension 1>>]

),

Root

(

[<<Target Dimension 2>>]

),

...

Root

(

[<<Target Dimension 1N>>]

),

[Measures].[<<Target Measure>>]

)

End

,

FORMAT_STRING = "Percent";

No comments:

Post a Comment