Forum Discussion
Need help finding duplicate Id's
I think i have a relatively easy ask but im going crazy. I have a table where i need to count the duplicate Id's. I create a simple count measure [ ID_Cnt=count(Id) ] then created another measure to identify the dups [ Duplicate_Cnt = if(ID_Cnt > 1), 1 , 0) ]. It just adds up all the Id's as if the condition wasnt even there. I would like to be to have the total number of duplicates associated with the ID and one measure that has the total count of all overall dups.
Any help is appreciated.
Here is an example of the data and my desired output:
Duplicates = 5
| Data | ID | Date | Result | ID | Dups | |
| 1 | 1/1/2021 | 1 | 1 | |||
| 9 | 1/2/2021 | 2 | 2 | |||
| 2 | 1/3/2021 | 4 | 1 | |||
| 4 | 1/4/2021 | 7 | 1 | |||
| 7 | 1/5/2021 | 9 | 3 | |||
| 9 | 1/2/2021 | |||||
| 9 | 1/2/2021 | |||||
| 2 | 1/3/2021 |
Duplicates = var aaa = ADDCOLUMNS(VALUES('Table'[ID]), "count id", CALCULATE(COUNT('Table'[ID]))) return IF( HASONEVALUE('Table'[ID]), SUMX(aaa, [count id]), SUMX(FILTER(aaa, [count id] > 1), [count id]) )EDIT - misread the requirements, have changed the calculation. The above is my attempt. I hope it helps!
3 Replies
- vicky_
Super User
Duplicates = var aaa = ADDCOLUMNS(VALUES('Table'[ID]), "count id", CALCULATE(COUNT('Table'[ID]))) return IF( HASONEVALUE('Table'[ID]), SUMX(aaa, [count id]), SUMX(FILTER(aaa, [count id] > 1), [count id]) )EDIT - misread the requirements, have changed the calculation. The above is my attempt. I hope it helps!
- DoubleTapNew Member
Works perfectly thank you so much!
- AnonymousNot applicable
Hi DoubleTap ,
Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.
If these also don't help, please share more detailed information and description to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng