dbTalk Databases Forums  

How to create a measure that shows the number of employees working under a Manager

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


Discuss How to create a measure that shows the number of employees working under a Manager in the microsoft.public.sqlserver.olap forum.



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

Default How to create a measure that shows the number of employees working under a Manager - 01-09-2004 , 05:06 PM






There is a "Employee" dimension that is built using the parent-child relationship on the source table columns named “employee_id” and “manager_id”. There is a need for a measure "Total People" whose value should be the count of the people working under a Manager. Obviously, the scope of this measure would be only along the “Employee” dimension, that is, the measure value changes only when the user drills along the “Employee” dimension. Since the Analysis Manager’s Cube Editor UI only allows measures to be selected from amonst the fact table columns, how can such a measure be created?

Reply With Quote
  #2  
Old   
Tom Chester
 
Posts: n/a

Default Re: How to create a measure that shows the number of employees working under a Manager - 01-09-2004 , 06:09 PM






Create a calculated member using this formula:

Descendants(Employees.CurrentMember).Count - 1

The -1 is because (oddly) MDX includes the member in the set.

public @ the domain below
www.tomchester.net


"Ravindra Babburi" <rbbabburi (AT) yahoo (DOT) com> wrote

Quote:
There is a "Employee" dimension that is built using the parent-child
relationship on the source table columns named "employee_id" and
"manager_id". There is a need for a measure "Total People" whose value
should be the count of the people working under a Manager. Obviously, the
scope of this measure would be only along the "Employee" dimension, that is,
the measure value changes only when the user drills along the "Employee"
dimension. Since the Analysis Manager's Cube Editor UI only allows measures
to be selected from amonst the fact table columns, how can such a measure be
created?




Reply With Quote
  #3  
Old   
Ravindra Babburi
 
Posts: n/a

Default Re: How to create a measure that shows the number of employees working under a Manager - 01-12-2004 , 12:26 PM



Using the formula "Descendants(Employees.CurrentMember).Count - 1" is giving a count where the summary members are also getting counted.
For example, in a scenario like thi
Employee
Employee
Employee
Employee
Employee
Employee
Employee
Employee
Employee
The count for Employee2 and Employee3 is correctly shown as 3 but for Employee1 the count is 10 instead of 8 since the summary rows for Employee2 and Employee3 are contributing a 2 to the count.
How can I avoid the counting of the summary members?

Reply With Quote
  #4  
Old   
Tom Chester
 
Posts: n/a

Default Re: How to create a measure that shows the number of employees working under a Manager - 01-12-2004 , 02:03 PM



Here you go:

Descendants(Employees.CurrentMember,,LEAVES).Count

public @ the domain below
www.tomchester.net


"Ravindra Babburi" <rbbabburi (AT) yahoo (DOT) com> wrote

Quote:
Using the formula "Descendants(Employees.CurrentMember).Count - 1" is
giving a count where the summary members are also getting counted.
For example, in a scenario like this
Employee1
Employee2
Employee4
Employee5
Employee6
Employee3
Employee7
Employee8
Employee9
The count for Employee2 and Employee3 is correctly shown as 3 but for
Employee1 the count is 10 instead of 8 since the summary rows for Employee2
and Employee3 are contributing a 2 to the count.
Quote:
How can I avoid the counting of the summary members?



Reply With Quote
  #5  
Old   
Ravindra Babburi
 
Posts: n/a

Default Re: How to create a measure that shows the number of employees working under a Manager - 01-12-2004 , 08:11 PM



Thanks Tom. That works.

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.