dbTalk Databases Forums  

Average

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


Discuss Average in the microsoft.public.sqlserver.olap forum.



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

Default Average - 09-22-2003 , 12:32 PM






Hi

Sorry if this is a simple question, I'm pretty new at this.

I'm creating a cube to use to store results of a survey we have just
conducted. I've built dimensions for all the answers and it's working great
so far.

Each answer is a number between 1 and 5, we now want to ask questions such
as "What was the average answer for Question 1", or "What was the average
answer broken down my CITY". I have a measure which currently just totals
up the answers and doesn't really mean anything, can I create a calculate
member to do what I need?

Thanks



Reply With Quote
  #2  
Old   
Jim Kaiser
 
Posts: n/a

Default Re: Average - 09-22-2003 , 01:44 PM






For computing simple averages at multiple levels, I add a RowCount field to
my fact table having a constant value of 1. Make it a measure, but set its
visible property to false. Then, create a calculated measure "Average" as
Datavalue/Rowcount. This will do Sum(Datavalue)/ Sum(Rowcount) at each
slicing.

If you make a dimension like "Aggregations" based on this RowCount field,
you can add this type of calculated measure to that dimension and have the
calculation available for any measure(s) you're looking at.

To compute a weighted average you pretty much have to add your weighting
calculations to the fact table, then divide by RowCount as above.

HTH
Jim

"Paul" <pe (AT) nospam (DOT) com> wrote

Quote:
Hi

Sorry if this is a simple question, I'm pretty new at this.

I'm creating a cube to use to store results of a survey we have just
conducted. I've built dimensions for all the answers and it's working
great
so far.

Each answer is a number between 1 and 5, we now want to ask questions such
as "What was the average answer for Question 1", or "What was the average
answer broken down my CITY". I have a measure which currently just totals
up the answers and doesn't really mean anything, can I create a calculate
member to do what I need?

Thanks





Reply With Quote
  #3  
Old   
Jim Kaiser
 
Posts: n/a

Default Re: Average - 09-22-2003 , 02:20 PM



Quote:
To compute a weighted average you pretty much have to add your weighting
calculations to the fact table, then divide by RowCount as above.

HTH
Jim

OK, brain fade, you don't of course divide the weighted value by RowCount,
but by the total of your weightings. A weighted average price, for example,
is P*V as a base measure in teh fact table divided by V as another base
measure. Of course, check for V <>0. This does sum(P*V) / Sum(V) at any
slicing. iif(Volume<>0, Revenue/volume, Null)




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

Default Re: Average - 09-22-2003 , 02:40 PM



Thanks I'll give that a go, I need to handle user who didn't respond to a
particular question, for that I think I'll have to create a rowcount var for
every question, and populate it with a 0 if they didn't answer.

Thanks for the ideas
Paul


"Jim Kaiser" <jkaiser-no-spam-att-henwoodenergy.com> wrote

Quote:
To compute a weighted average you pretty much have to add your weighting
calculations to the fact table, then divide by RowCount as above.

HTH
Jim

OK, brain fade, you don't of course divide the weighted value by RowCount,
but by the total of your weightings. A weighted average price, for
example,
is P*V as a base measure in teh fact table divided by V as another base
measure. Of course, check for V <>0. This does sum(P*V) / Sum(V) at any
slicing. iif(Volume<>0, Revenue/volume, Null)





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.