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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
adbm
Regular Visitor

Countifs to identify duplicates in dataset

Hi,

 

I have the purchase register of a company and I'm trying to identify and present duplicate entries in it using power bi. In excel i would've normally used the countifs function. Eg. if my table were as below, i would add a countifs column whose formula would be COUNTIFS($C:$C,C2,$D:$D,D2). This formula would then give me a result of 2 for vendor id 600754 and 1 for the other vendor ids. the idea is to analyse all rows returning values greater than 1. Is there a way to achieve this result in PBI as well? I've gone trhough numerous posts on this topic but none of the solutions provided (consisting of using earlier / a combination of calculate, filter and countrows etc.) do not seem to work or i'm not able to customise them as per my needs. 

 

Thank you for your help.

 

ABCD
Vendor ID.#NameInvoice No.# Transaction Amount 
600754aaaa123366
989111bbbb234320
242001cccc86030242
600754aaaa123366
1 ACCEPTED SOLUTION
Irwan
Solution Sage
Solution Sage

hello @adbm 

 

there are couple ways to do this depend on what/how you want to show those data.

but in order to check duplicate, here are some ways. 

1. using table visual. just drop your column value and this visual will automatically show one value per same value.

Irwan_0-1725514540710.png

2. use measure. as you can see, the duplicate value will be indicated by value over than 1.

Irwan_1-1725514588364.png

Duplicate = 
var _Vendor = SELECTEDVALUE('Table'[Vendor ID.#])
var _Dupl = CALCULATE(COUNT('Table'[Vendor ID.#]),ALLSELECTED('Table'),'Table'[Vendor ID.#]=_Vendor)
Return
_Dupl

3. use calculated column. Similarly to measure above, but using calculated column (one with EARLIER() and another without EARLIER()).

Irwan_2-1725514664772.png

Irwan_3-1725514681565.png

 

Hope this will help.

Thank you.

View solution in original post

3 REPLIES 3
Irwan
Solution Sage
Solution Sage

hello @adbm 

 

there are couple ways to do this depend on what/how you want to show those data.

but in order to check duplicate, here are some ways. 

1. using table visual. just drop your column value and this visual will automatically show one value per same value.

Irwan_0-1725514540710.png

2. use measure. as you can see, the duplicate value will be indicated by value over than 1.

Irwan_1-1725514588364.png

Duplicate = 
var _Vendor = SELECTEDVALUE('Table'[Vendor ID.#])
var _Dupl = CALCULATE(COUNT('Table'[Vendor ID.#]),ALLSELECTED('Table'),'Table'[Vendor ID.#]=_Vendor)
Return
_Dupl

3. use calculated column. Similarly to measure above, but using calculated column (one with EARLIER() and another without EARLIER()).

Irwan_2-1725514664772.png

Irwan_3-1725514681565.png

 

Hope this will help.

Thank you.

adbm
Regular Visitor

Hi Irwan,

 

Thanks for that.

 

Solution 1 is easier but i want to be able to see the rows that are repeated so i need to see the count over 1. Solution number 2 didnt seem to work. Solution 3 with earlier worked for me. I used a calculated column as suggested by you with countrows and earlier and that seemed to work for me.

 

Thanks for all your help!

 

Best, 

Natali

hello @adbm 

 

solution 2 need you to make a table visual since it is a measure.

 

but anyway, glad it works.

 

Thank you.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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