Recently, I was asked to write a calculation that calculates the ratio to parent on rows that doesn’t depend on cube structure and that also works in OWC. The first part I managed to dig somewhere from the past, the second proved to be much more demanding task. Having bypassed several obstacles and spent significant portion of time on this subject, I decided to pass the knowledge in form of a blog article. Here’s the calculation:
CREATE MEMBER CURRENTCUBE. [Measures].[Universal share percent for OWC in BIDS %] AS iif( IsError( Extract( Axis(0), Measures ).Item(0) ), iif( IsError( Extract( Axis(1), Measures ).Item(0) ), iif( Axis(1).Item(0).Item( Axis(1).Item(0).Count - 1 ) .Hierarchy.CurrentMember.Level.Ordinal = 0, 1, Extract( Axis(2), Measures ).Item(0) / ( Axis(1).Item(0).Item( Axis(1).Item(0).Count - 1 ).Hierarchy.CurrentMember.Parent, Extract( Axis(2), Measures ).Item(0) ) ), iif( Axis(0).Item(0).Item( Axis(0).Item(0).Count - 1 ) .Hierarchy.CurrentMember.Level.Ordinal = 0, 1, Extract( Axis(1), Measures ).Item(0) / ( Axis(0).Item(0).Item( Axis(0).Item(0).Count - 1 ).Hierarchy.CurrentMember.Parent, Extract( Axis(1), Measures ).Item(0) ) ) ), iif( IsError( Axis(1).Item(0) ), 1, iif( Axis(1).Item(0).Item( Axis(1).Item(0).Count - 1 ) .Hierarchy.CurrentMember.Level.Ordinal = 0, 1, Extract( Axis(0), Measures ).Item(0) / ( Axis(1).Item(0).Item( Axis(1).Item(0).Count - 1 ).Hierarchy.CurrentMember.Parent, Extract( Axis(0), Measures ).Item(0) ) ) ) ),FORMAT_STRING = "Percent", VISIBLE = 1;
What’s good about it is that it can be used in any project.
I also enhanced it a bit, to support other clients/controls as well (SSMS included).
Finally, it can be used as a template for other calculations that use Axis() function and are intended to work in Cube Browser.
ATTENTION: The improved variant of the same calculation can be found in a more recent blog article here.