Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Manager Count/Filter Code

Hi Folks,

 

I have the following dataset as an example: 

 

EE IDNameEE TypeManager IDManager Name
11111Bell, TacoContractor22241Frog, Kermit
11112Jones, JessicaEmployee22241Frog, Kermit
22241Frog, KermitEmployee65584Blue, Gonzo
333544Piggy, MissEmployee65656Animal, Wild
65584Blue, GonzoEmployee22241Frog, Kermit
65656Animal, WildContractor11114Piano, Rowlf

 

We have a number of managers in our company as notated in the last column. Those managers are also employees as you can see in column 2 (I didn't build them all out). We also have two types of employees: employee and contractor. However, we do not consider a manager a "people manager" unless they are managing at least one employee.

 

What I want to do is get a DISTINCT COUNT of how many managers are managing EMPLOYEE's. So in this example, the count would be 3 because we have Kermit Frog, Gonzo Blue, and Wild Animal. Rowlf should not show up as part of the count because he's only managing a contractor. 

 

I know when I do a DISTINCTCOUNT DAX to get the number of managers by ID it gives me 4, which is great, but I want it to only give me 3 because Rowlf only has a contractor. 

 

I tried using DISTINCTCOUNT and FILTER but I can't seem to get it right. Any help would be great please. 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

I created a measure

 

Count of Manager = CALCULATE(DISTINCTCOUNT(Employee[Manager ID]), FILTER(Employee, Employee[EE Type] = "Employee"))

 

I got count 3. Could you please try this and see if it works for you?

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

 

I created a measure

 

Count of Manager = CALCULATE(DISTINCTCOUNT(Employee[Manager ID]), FILTER(Employee, Employee[EE Type] = "Employee"))

 

I got count 3. Could you please try this and see if it works for you?

Anonymous
Not applicable

That is exactly what I needed. I was doing '&&' instead of "," between DISTINCTCOUNT and FILTER. Glad to know I wasn't far off. Thank you!

Anonymous
Not applicable

That is exactly what I needed. I was doing '&&' instead of "," between DISTINCTCOUNT and FILTER. Glad to know I wasn't far off. Thank you!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.