Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Analysis Services (2000)
 Trouble with the Sum() Function

Author  Topic 

tygun1
Starting Member

1 Post

Posted - 2004-05-20 : 14:04:11
I am trying to utilize the Sum() function to create a calculated member tha ultimately gives me the percent of the total count.

Heres a simplified scenario

I have a Measure called Product Group. Lets say I have 3 products

apples, oranges, coconuts

Now lets say I have a measure that counts the orders for these so the data would look like this

Product Count of orders

All 100

Oranges 30

Apples 50

Coconuts 20

I want a calculated member that would give me the percentage of orders that each product represents (i.e. the column next to the oranges count would be 30% becasue 30 orders out of 100 is 30%, and so on). I thought this would be a piece of cake, but I guess I'm not that smart.

Can someone please help me with this.

Thanks in advance, Scott

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-05-20 : 14:25:04
Try something like this:

SELECT Product, count(orders)/((select count(b.orders) from myTable b)* 1.00)
from myTable
GROUP BY Product
Go to Top of Page
   

- Advertisement -