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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
kellyylx
Helper I
Helper I

count number of true for each country

Hi I have a table of people information from various countries and column 'duplicates' is a true/false column that indicates if that record has a duplicate in the dataset based on their name. (e.g. if 2 records have the same name, value in duplicates is true)

 

I want to count the number of duplicates for each country (aka counting the number of rows where duplicates='true' grouped by the country)

 

How can i do so?

3 REPLIES 3
Anonymous
Not applicable

Hello,Bibiano_Geraldo and danextian ,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

Hi,@kellyylx , I am glad to help you.
Like this?
I verified the suggestions of others as well, and the end result is as follows:

vjtianmsft_0-1732863806717.png

Count of Duplicates = 
CALCULATE(
    COUNTROWS('TableTest'),
    'TableTest'[duplicates] = TRUE()
)

Count_Duplicates02 = 
CALCULATE (
    COUNTROWS ( 'TableTest'),
    KEEPFILTERS ('TableTest'[duplicates] = TRUE () )
)


M_all =
CALCULATE (
    COUNTROWS ( 'TableTest' ),
    FILTER ( ALL ( 'TableTest' ), 'TableTest'[duplicates] = TRUE () )
)

 this is my test data:

Name

Country

duplicates

Index

John Doe

USA

True

1

Jane Smith

Canada

False

2

John Doe

USA

True

3

Alice Johnson

Canada

True

4

Bob Brown

USA

False

5

Alice Johnson

Canada

True

6

Charlie Brown

USA

False

7

David Wilson

Canada

False

8

Eva Green

USA

False

9

Frank White

Canada

False

10

 

vjtianmsft_1-1732863899520.png


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

danextian
Super User
Super User

Hi @kellyylx 

Create this measure then add that to a table viz together with the country column

CALCULATE (
    COUNTROWS ( 'table' ),
    KEEPFILTERS ( 'table'[duplicates] = TRUE () )
)

I am assuming that  duplicates column is of type boolean/logical. If not, replace TRUE() with "true"





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Bibiano_Geraldo
Super User
Super User

Hi @kellyylx ,

Create a measure with the following DAX:

Count of Duplicates = 
CALCULATE(
    COUNTROWS('YourTable'),
    'YourTable'[duplicates] = TRUE()
)

Add this measure to a visual, like a table, with the Country column to see the count of duplicates for each country.

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.