Forum Discussion
Count rows in a table visual that is filtered by a count
I have a table visual that is showing data for all the users who have more than 1 Team. I filter that visual to only show the data where the count of teams is greater than 1. I want to get a count of the rows in the filtered table visual. Feels like this should be really easy, but my internet searches are not helping. Looking at the table below, I want to count the number of users
| User | Count |
| user 1 | 3 |
| User 2 | 4 |
| User 3 | 2 |
4 Replies
- AllisonKennedy
Community Champion
Create a measure for Count Users:
Count Users = DISTINCTCOUNT(Usertable[User])
This should respond to any filters you apply.
If all your data is in one table though and you don't have a User table you'll need more DAX. Please send screenshot of your model relationships veiw if that is the case.
- AnonymousNot applicable
Hi jofoster ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Measure = COUNTROWS(ALLSELECTED('Table_Count')2. Result:
When there is no filtering, the total number is displayed:
When the filter Count> 1, the number of rows after the filter is displayed:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- AllisonKennedy
Community Champion
jofoster Are you still having trouble with this? Can you please update the community either way and let us know how you're getting on?
Anonymous Why have you marked Anonymous 's post as the solution? I do agree that Liu Yang gave much more images and detail, but that does not make their response a solution. jofoster has not provided enough information about their dataset for us to know if Anonymous 's measure will work. The measure Anonymous provided will only work if the data jofoster is working with is already summarized and grouped by User, which in most datasets this is not the case.
In the post by Anonymous there is only 1 row per user in the raw data, so the measure they have provided will work in this very specific use case:
However, if I generate more realistic data which has multiple rows per user, but only 5 users:
This gives the table visual that jofoster mentioned in their original post:
However, using the Anonymous will count ALL the ROWS, not ALL the USERS.
As I mentioned in my original post, this problem will be very easy if there is a UserTable:
Here is more info on Dim tables for reference: https://excelwithallison.blogspot.com/2020/08/its-complicated-relationships-in-power_11.html
I haven't heard from jofoster with any clarification or questions, so can't know what their data looks like or if this is solved or if they already have a user table dimension.Please see attached file below my signature for the detailed solution, and more expanded to work for Grand Total even when user is filtered in visual. It also shows why I have made the difficult decision to unmark the Anonymous post as a solution, because I do not want others to be mislead and get confused. As you can see in the image below, their post returns 9 total users, when there are only 5. Even if I filter the table, it still returns the incorrect value of 7:
Everything depends on the data model, for reference here is the data model I have used:
Thanks to Anonymous for your post and detailed images and help.
jofoster Please do let us know if this is resolved.
Thanks!
- AllisonKennedy
Community Champion
Oh, and the measure that answers the question with filters already included:
Count Users with more than 1 Team =COUNTROWS(FILTER(Users, [Team Count] > 1))