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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
geoffgarcia
Helper I
Helper I

Count rows in another table that match the current row

I've spend a healthy amount of time looking for a solution and am posting here as a last hope.

I have a table of offices and a table of employees, and very simply need to find a count of all employees in an office.

I'd like to add the employee count as a calculated column to my Offices table.

I've tried a number of things but nothing has gotten me the results I expect (red font below).

Any suggestions?

 

Table: Offices

Office_IDEmployee_Count (calculated column)
NY6563
NJ9991
CT0011

 

Table: Employees

Employee_IDOffice_ID
1001NY656
1002NY656
1003NY656
1004NJ999
1005CT001

 

 

1 ACCEPTED SOLUTION

Looks like it works as a measure too. I did have to tell the column to SUM though.

image.pngimage.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
ChrisMendoza
Resident Rockstar
Resident Rockstar

A column could have been:

image.png

I presume your desired solution is a measure then.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thanks Chris - that is so simple! I'm still a little lost on a measure versus a column, but will take a look.

TY!

Looks like it works as a measure too. I did have to tell the column to SUM though.

image.pngimage.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



geoffgarcia
Helper I
Helper I

The rule of Geoff is within 5 minutes of asking a question I figure it out on my own. I believe the answer is:

EmployeeCount = 
var _CurrentRowValue = Office[Office_ID]
RETURN
COUNTROWS(
    Filter(Employees,
    _CurrentRowValue=Employees[Employee_ID]
))

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.