dbTalk Databases Forums  

percentage based on the current filter

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


Discuss percentage based on the current filter in the microsoft.public.sqlserver.olap forum.



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

Default percentage based on the current filter - 01-24-2006 , 09:02 AM






Hi to all,
I built a calculated member showing the percentage of a certain
measure over more dimensions.
For example,
I have 3 dimensions, d1,d2 and d3 and a measure m1. My calculated
member (called P), is the percentage of m1 on the total.

So, when I don't apply any filter on dimensions d2 and d3 i have the
following result:
-----------------------------------------------------------------------------------------------------------------
All dim2
All dim3
-----------------------------------------------------------------------------------------------------------------
M P (%)
All dim1 20 100%
1st member of d1 2 10%
2nd member of d1 6 30%
3rd member of d1 4 20%
4th member of d1 8 40%
-----------------------------------------------------------------------------------------------------------------
and it works fine.

But, assuming d2 is a time dimension, when I filter d2 = 2005 instead
of "All times", the previous table shows all the values considering
only the year 2005:

-----------------------------------------------------------------------------------------------------------------
dim2 = 2005
All dim3
-----------------------------------------------------------------------------------------------------------------
M P (%)
All dim1 5 25%
1st member of d1 0 0%
2nd member of d1 1 5%
3rd member of d1 1 5%
4th member of d1 3 15%
-----------------------------------------------------------------------------------------------------------------

Now my question is:
how can I have a percentage Q that considers filtered and shown data
always if they were the 100% of the measure? I would like to have, in
the second example, the following result:

-----------------------------------------------------------------------------------------------------------------
dim2 = 2005
All dim3
-----------------------------------------------------------------------------------------------------------------
M P (%)
All dim1 5 100%
1st member of d1 0 0%
2nd member of d1 1 20%
3rd member of d1 1 20%
4th member of d1 3 60%
-----------------------------------------------------------------------------------------------------------------

Any suggestion will be valued!!!!!
Gabriele


Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: percentage based on the current filter - 01-26-2006 , 12:46 AM






Hi Gabriele,

If you could give an idea of the MDX you used in the calculated measure,
it may provide some more clues.


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***

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

Default Re: percentage based on the current filter - 01-28-2006 , 11:38 AM



I used the following MDX:
"([Measures].[M])/([Measures].[M],[dim1].DefaultMember,[dim2].DefaultMember,[dim3].DefaultMember)"
Thanks you a lot in advance!


Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: percentage based on the current filter - 01-29-2006 , 01:25 AM



Since you're interested in percentage of total on rows of the query
(regardless of filter conditions), try an approach like this sample from
Tom Chester:

http://www.tomchester.net/articlesdo...desamples.html
Quote:
Flexible Percent of Total

Works with any set and any measure (assumes measure being operated upon
is in first column)

WITH MEMBER Measures.[% Total] AS

' ( StrToSet("Axis(1)").Item(0).Item(0).Dimension.Curr entMember, --
cur row mbr

StrToSet("Axis(0)").Item(0).Item(0) ) / --
1st measure on cols

( StrToSet("Axis(1)").Item(0).Item(0), --
assume 1st row=total

StrToSet("Axis(0)").Item(0).Item(0) ) ' , --
1st measure on cols

Format_String = '0%'



SELECT

{ [Store Sales] , [% Total] } ON AXIS(0),

{ Product.DefaultMember, [Product Family].Members} ON AXIS(1)

FROM Sales
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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.