dbTalk Databases Forums  

MDX Percentage Calculation

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss MDX Percentage Calculation in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joe Murray
 
Posts: n/a

Default MDX Percentage Calculation - 06-16-2006 , 06:56 PM






I want to display a couple of percentages based on counts. My cube only
displays counts. I want one calculation that displays the "percentage of
all" and another one that is the "percentage of displayed" .

This is in essence of what I want:

[Percent of All] = [Measures].[Count] / [Total Rows in Cube?]
[Percent of Displayed] = [Measures].[Count] / [Sum of currently displayed
Measures.Count?]

Does anyone know how to do this?

Thanks,

Joe


Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: MDX Percentage Calculation - 06-18-2006 , 06:09 AM






The following does a "percent of parent", "percent of total" along the
Product Categories hierarchy in the Adventure Works DW database.

Quote:
WITH MEMBER measures.pcntOfParent as ([Product].[Product
Categories].CurrentMember, Measures.[Internet Sales Amount])
/ (iif([Product].[Product Categories].CurrentMember.Parent is null
,[Product].[Product Categories].CurrentMember
,[Product].[Product Categories].CurrentMember.Parent),
Measures.[Internet Sales Amount]), FORMAT_STRING = "0.00%"
MEMBER measures.pcntOfTotal as ([Product].[Product
Categories].CurrentMember, Measures.[Internet Sales Amount])
/ ([Product].[Product Categories].[All Products], Measures.
[Internet Sales Amount]), FORMAT_STRING = "0.00%"
SELECT
{ Measures.[pcntOfParent], Measures.pcntOfTotal } ON COLUMNS
, {[Product].[Product Categories].Members} ON ROWS
FROM [Adventure Works]


Quote:
Creating a "percent of displayed" measure is a lot more difficult to do
generically. You could look at the axis() function to try and figure out
what the users are querying, but it is easier to take the percentage
from a fixed point of reference.

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1150582359.533297.265910 (AT) g10g2000cwb (DOT) googlegroups.com>,
willrich33 (AT) yahoo (DOT) com says...
Quote:
Joe:

I actually need to know this stuff so I will pass it on...

I had some success with

sum(nonempty(EXISTING crossjoin([Commercial Cube].[Brand].members,
{[Measures].[Daily Weight]})))

in AS 2005....

I was using this stuff to calculate the market share by category...

ie Crest/Total Toothpaste

where I had many categories...

HTH, Willy


willy wrote:
Joe:

Maybe not...I tried this and got recursion..

iif(isleaf([Commercial Cube].[Brand].currentmember),
[Measures].[Daily Weight]/sum([Commercial Cube].[Brand].currentmember),
null)

You can look at the post.."Select Multiple - Infinite recusion
situation." I tried this syntax with a sum instead of count and got an
error...

Sorry I can't help more...I will follow your thread to see if anyone
has a better way...

Willy


Joe Murray wrote:
I am on SSAS 2005. There has to be an easier way?


"willy" wrote:

Joe:

I have assumed you are using AS2000, if you are on AS2005 I am not sure
how to proceed.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.