dbTalk Databases Forums  

Percentage across a dimension?

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


Discuss Percentage across a dimension? in the microsoft.public.sqlserver.olap forum.



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

Default Percentage across a dimension? - 06-01-2004 , 08:52 AM






Greetings,

I'm very new to MDX, so please bear with me..

Basicly I need a calculated member.

I have many different dimensions, and all of them are being used (for
filtering, not on rows/columns). On rows I have dimension Variant
(which can be 'I', 'II', etc).

Now, what I need is %age of that Variant of all the Variants. Eg,
leaving all the filtering by other dimensions, i need a member which
would show how many % is Variant 'I' of all Variants..

How can that be done?

Thank you.

Reply With Quote
  #2  
Old   
Hans van Kruijssen
 
Posts: n/a

Default Re: Percentage across a dimension? - 06-01-2004 , 10:15 AM






Algirdas wrote:
Quote:
Greetings,

I'm very new to MDX, so please bear with me..

Basicly I need a calculated member.

I have many different dimensions, and all of them are being used (for
filtering, not on rows/columns). On rows I have dimension Variant
(which can be 'I', 'II', etc).

Now, what I need is %age of that Variant of all the Variants. Eg,
leaving all the filtering by other dimensions, i need a member which
would show how many % is Variant 'I' of all Variants..

How can that be done?
Suppose you have a measure value and a level named variantLevel in the
variant dimension.

<MDX>
WITH
MEMBER [Measures].[Variant Percentage] AS
'( [Variant].CurrentMember, [Measures].[Value] ) /
Sum( [Variant].[VariantLevel].Members, [Measures].[Value] )',
FORMAT_STRING = 'Percent'

SELECT
{[Variant].[VariantLevel].Members} ON ROWS,
{[Measures].[Variant Percentage]} ON COLUMNS
FROM
CubeName
</MDX>

Hope this helps,

Hans.


Reply With Quote
  #3  
Old   
Algirdas
 
Posts: n/a

Default Re: Percentage across a dimension? - 06-02-2004 , 12:03 AM



I'll surely try it once I get back to work - thanks!

"Hans van Kruijssen" <hans.vanKruijssen (AT) agilisys (DOT) com> wrote

Quote:
Algirdas wrote:
Greetings,

I'm very new to MDX, so please bear with me..

Basicly I need a calculated member.

I have many different dimensions, and all of them are being used (for
filtering, not on rows/columns). On rows I have dimension Variant
(which can be 'I', 'II', etc).

Now, what I need is %age of that Variant of all the Variants. Eg,
leaving all the filtering by other dimensions, i need a member which
would show how many % is Variant 'I' of all Variants..

How can that be done?

Suppose you have a measure value and a level named variantLevel in the
variant dimension.

MDX
WITH
MEMBER [Measures].[Variant Percentage] AS
'( [Variant].CurrentMember, [Measures].[Value] ) /
Sum( [Variant].[VariantLevel].Members, [Measures].[Value] )',
FORMAT_STRING = 'Percent'

SELECT
{[Variant].[VariantLevel].Members} ON ROWS,
{[Measures].[Variant Percentage]} ON COLUMNS
FROM
CubeName
/MDX

Hope this helps,

Hans.

Reply With Quote
  #4  
Old   
QQ
 
Posts: n/a

Default RE: Percentage across a dimension? - 06-02-2004 , 12:06 AM



Out of sheer curiosity - how would that look if i'd needed to get
percentage of ALL Variants, and say ALL Dates (or any other dimension), eg
combine two full dimensions (while leaving all other filters) to produce
the percentage?

"=?Utf-8?B?cHJ5bHk=?=" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
news:9BEEB491-61DF-4D4A-8983-E20B3D0B0DBB (AT) microsoft (DOT) com:

Quote:
if you have a all member in variant dimension, then your calculated
member should be:

[variant].currentmember/[variant].[all]



Reply With Quote
  #5  
Old   
Hans van Kruijssen
 
Posts: n/a

Default Re: Percentage across a dimension? - 06-02-2004 , 03:34 AM



QQ wrote:

Quote:
Out of sheer curiosity - how would that look if i'd needed to get
percentage of ALL Variants, and say ALL Dates (or any other
dimension), eg combine two full dimensions (while leaving all other
filters) to produce the percentage?

([Variant].CurrentMember,[Dates].CurrentMember, [Measures].[Value]) /
([Variant].[All Variant], [Dates].[All Dates], [Measures].[Value])

or alternatively ( [Measures].[Value] is short for the tuple with all
CurrentMembers for the dimensions.

[Measures].[Value] /
([Variant].[All Variant], [Dates].[All Dates], [Measures].[Value])

In MDX it is very important to understand the concept of tuples.
The helpfile contains a pretty detailed explanation of this concept.

Hope this helps,


Hans.


Reply With Quote
  #6  
Old   
QQ
 
Posts: n/a

Default Re: Percentage across a dimension? - 06-08-2004 , 01:36 AM



Quote:
([Variant].CurrentMember,[Dates].CurrentMember, [Measures].[Value]) /
([Variant].[All Variant], [Dates].[All Dates], [Measures].[Value])
When trying that, I get "cannot find member" when trying [All ...], and
when I replace that with .AllMembers, I get unexpected token at ","..

what am I doing wrong?


Reply With Quote
  #7  
Old   
Hans van Kruijssen
 
Posts: n/a

Default Re: Percentage across a dimension? - 06-08-2004 , 03:14 AM



QQ wrote:

Quote:
([Variant].CurrentMember,[Dates].CurrentMember, [Measures].[Value])
/ ([Variant].[All Variant], [Dates].[All Dates],
[Measures].[Value])

When trying that, I get "cannot find member" when trying [All ...],
and when I replace that with .AllMembers, I get unexpected token at
","..

what am I doing wrong?
Make sure you created an All Level for the dimension, and maybe you
changed the name of the all level. If there is no all level and you
don't intend to create one, a worakround would be to replace the second
line with for example:

Sum( [Variant].[HighestLevel].Members, Sum( [Dates].[HighestLevel],
[Measures].[Value] ) )

Or use another appropiate aggregation function that you are using for
date and/or variant.


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.