dbTalk Databases Forums  

MDX expression in order to get %

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


Discuss MDX expression in order to get % in the microsoft.public.sqlserver.olap forum.



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

Default MDX expression in order to get % - 05-06-2004 , 02:07 PM






Hi,

I'm fairly new to MDX and can not figure out how to write
an expression.

I have a 4 dimensions currently, let's use
Client_Category for this example. Under Client_Category
I have 2 levels Client and Category. I also have 3
measures, let's use On Time for this example.

Within my fact table I have a field On Time. This field
is populated with 1 or 0, 1 = on time and 0 = late. What
I'd like to do is show an on time % for a client. In
order to retrieve this answer you would need to add all
the instances of the client and divide that by sum the on
time field.

If the data looked like this

Client On Time
A 1
A 0
A 1
A 1

The result would return 75% 3/4.

Thanks for any assistance.


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

Default Re: MDX expression in order to get % - 05-06-2004 , 07:57 PM






Assuming that the [On Time] cube measure sums the [On Time] fact table
field, you also need a cube count measure, say [Sample Count]. This
count aggregation can be defined on any fact table field. Then, define a
Calc. Measure like:

Quote:
With Member [Measures].[On Time Fraction] as
'[Measures].[On Time]/[Measures].[Sample Count]',
FORMAT_STRING = 'Percent'

Select {[Measures].[On Time Fraction]} on Columns,
[Client_Category].[Client].Members on Rows

From MyCube
Quote:

- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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

Default Re: MDX expression in order to get % - 05-07-2004 , 09:57 AM



Awesome. Thanks Deepak. This has me going in the right
direction.

Jason

Quote:
-----Original Message-----
Assuming that the [On Time] cube measure sums the [On
Time] fact table
field, you also need a cube count measure, say [Sample
Count]. This
count aggregation can be defined on any fact table
field. Then, define a
Calc. Measure like:


With Member [Measures].[On Time Fraction] as
'[Measures].[On Time]/[Measures].[Sample Count]',
FORMAT_STRING = 'Percent'

Select {[Measures].[On Time Fraction]} on Columns,
[Client_Category].[Client].Members on Rows

From MyCube



- Deepak

*** Sent via Developersdex http://www.developersdex.com
***
Don't just participate in USENET...get rewarded for it!
.


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.