PDA

View Full Version : [SOLVED:] Keep 1 Record every 5 duplicate



asemaan
02-27-2020, 10:51 PM
Hi

i have a large database with a lot of duplicates
i need to keep 1 record for each 5 duplicate.
example if i have 2 to 9 duplicate keep 1
if i have 10 to 14 keep 2
if i have 15 to 19 keep 3
if i have 61 record keep 12, etc..

can anyone help please.
thank you

p45cal
02-28-2020, 04:04 AM
It depends on how many columns you take into account before you call something a duplicate.
If it's only one column, then you can add a formula such as:
=MIN(COUNTIF(A$2:A2,A2),MAX(1,INT(COUNTIF($A$2:$A$76,A2)/5)))
in column B then use Excel's built in Remove Duplicates looking at just columns A and B.
See attached where the formula's been applied but the Remove Duplicates hasn't.
Better to attach a workbook with a bit more detail and what you expect the result to be.

asemaan
03-04-2020, 02:51 AM
Thank you for your reply.
actually i have 4 columns to be counted
i have attached a sample of the data, and on the right the result.

thank you again
Regards
Aziz

p45cal
03-04-2020, 08:22 AM
Delete column E entirely.
In the new column E (no merged cells) in cell E2:

=MIN(COUNTIFS(A$2:A2,A2,B$2:B2,B2,C$2:C2,C2,D$2:D2,D2),MAX(1,INT(COUNTIFS($ A$2:$A$46,A2,$B$2:$B$46,B2,$C$2:$C$46,C2,$D$2:$D$46,D2)/5)))
copy down.
Remove Duplicates using all 5 columns.
Delete column E.

asemaan
03-05-2020, 01:17 AM
Thank you so much, it worked.
Regards
Aziz