cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
savage63073
Frequent Visitor

Count Values leveraging a unary relationship

Hi,

 

I am learning Power BI - hope this question is not too obvious.

 

I am trying to create a measure which counts values in a data set through a unary relationship.  It's an employee table which includes the employee's manager ID.  I want the measure to tell me, for each employee, how many other employees they manage.  The image included articulates it pretty well - trying to create the "Number Direct Reports" column.  Appreciate any ideas, thanks!

 

CountNumDirReports.JPG

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @savage63073 

Please check the below picture and the measure.

 

Picture3.png

 

 Number of Direct Reports From =
VAR currentid =
MAX ( Data[EmpID] )
RETURN
CALCULATE (
COUNTROWS ( Data ),
FILTER ( ALL ( Data ), Data[ManagerID] = currentid )
) + 0

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @savage63073 

Please check the below picture and the measure.

 

Picture3.png

 

 Number of Direct Reports From =
VAR currentid =
MAX ( Data[EmpID] )
RETURN
CALCULATE (
COUNTROWS ( Data ),
FILTER ( ALL ( Data ), Data[ManagerID] = currentid )
) + 0

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

awesome, thank you!

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!