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
msft-cap
Helper II
Helper II

Incorrect rows returned with countrows and filter function

I am using below DAX formulas to count the number of clients with Rating A to D. I am getting count as 8 even though the number of records is 5.

Any thoughts on what is going wrong here.

 

Client_count = Countrows(filter('ClientDetail','ClientDetail'[ClientRating] in { "A", "B", "C","D"}))

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @msft-cap ,

 

Please make sure whether there are duplicate column combiantions like [Name] and [ClientRating] in your data model. 
For example: There may be two or more Name = C01 and ClientRating = C in your data model. Then you will count more than 5.

My Sample:

RicoZhou_0-1658218550852.png

In table visual I could only see five records, due to Power BI will only show duplicates once. Your measure will return 8 in my sample.

RicoZhou_2-1658218663229.png

Try this code.

Client_count =
COUNTROWS (
    SUMMARIZE (
        FILTER ( ClientDetail, 'ClientDetail'[ClientRating] IN { "A", "B", "C", "D" } ),
        ClientDetail[Name],
        ClientDetail[ClientRating]
    )
)

Result is as below.

RicoZhou_3-1658218814273.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

4 REPLIES 4
jcalheir
Solution Supplier
Solution Supplier

Hi

 

Try using a calculate function:

 

Client_count = 
CALCULATE(
    COUNTROWS('ClientDetail'),
    'ClientDetail'[ClientRating] in { "A", "B", "C","D"}
)

 

Kind regards,
José
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Jihwan_Kim
Super User
Super User

Hi,

I think your measure seems correct.

Please check the below picture and the attached file.

I tried to create a sample pbix file like below. If your data model looks different, please share your sample pbix file's link here, and then I can try to look into it to come up with an accurate solution.

Thanks.

 

Picture4.png


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


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim My report has about 400 records and only 5 records has clientRating either C or D. rest all are null. When I added the ClientRating field to table format, I get 5 records and rest all records has null/blank. I am not sure why I keep getting 8 count with the above DAX formula. 

I am unable to share report due to data confidentiality and mock up example just work fine as you shared. 

Anonymous
Not applicable

Hi @msft-cap ,

 

Please make sure whether there are duplicate column combiantions like [Name] and [ClientRating] in your data model. 
For example: There may be two or more Name = C01 and ClientRating = C in your data model. Then you will count more than 5.

My Sample:

RicoZhou_0-1658218550852.png

In table visual I could only see five records, due to Power BI will only show duplicates once. Your measure will return 8 in my sample.

RicoZhou_2-1658218663229.png

Try this code.

Client_count =
COUNTROWS (
    SUMMARIZE (
        FILTER ( ClientDetail, 'ClientDetail'[ClientRating] IN { "A", "B", "C", "D" } ),
        ClientDetail[Name],
        ClientDetail[ClientRating]
    )
)

Result is as below.

RicoZhou_3-1658218814273.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

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.