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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Countrows - Counting all rows of table, although filtered

Hi, 

I'm trying to replicate the Excel function COUNTIF, to count how many times a manager's name appears in a table. I have read numerous guides on this, and tried a few different ways of solving it, but all end up in the same way. Counting all rows, instead of the ones filtered. 

Here is one of the measures I use in a column:

 

Team size = CALCULATE(COUNTROWS(Table2),FILTER(Table2,Table2[Manager]=Table2[Manager]))
 
I want it to output a number saying how many that shares that manager, but it outputs the total number of rows in the entire table. 

What am I doing wrong? 

Many thanks! 
1 ACCEPTED SOLUTION

@Anonymous , the Above formula, should work for what you shown in excel

Team size = CALCULATE(COUNT(Table2[Manager]),FILTER(allselected(Table2),Table2[Manager]=max(Table2[Manager])))

 

or

Team size = CALCULATE(COUNT(Table2[Manager]),Allexcept(Table2,Table2[Manager]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , the expected output is not clear . But try like 

 

Team size = CALCULATE(COUNTROWS(Table2),FILTER(allselected(Table2),Table2[Manager]=max(Table2[Manager])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak. It did not work, unfortunately. It outputed the same value in all rows as well. 

I'm adding a print screen of an excel with my wanted output, hope it explains. 

frej-engstrom_0-1614765980408.png

 

@Anonymous , the Above formula, should work for what you shown in excel

Team size = CALCULATE(COUNT(Table2[Manager]),FILTER(allselected(Table2),Table2[Manager]=max(Table2[Manager])))

 

or

Team size = CALCULATE(COUNT(Table2[Manager]),Allexcept(Table2,Table2[Manager]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Many thanks @amitchandak . Worked like a charm! 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors