Formula to find duplicates that match 2 different values in a row

matratus34

Board Regular
Joined
Nov 21, 2013
Messages
74
PRODUCT ID
PRICE
A123
1.66
A123
1.66
A134
1.22
A145
2.34
A134
1.24
A167
1.26
A129
1.67

<tbody>
</tbody>
Hi Guys, I got a list of data today, about 30000 rows with 20 different column headers.
To put my problem simply I had a product ID in column A and a price in column B.
There were 1000s of duplicates in the product ID but the price wasn't always duplicated in column B (sometimes it was different)
What I needed to do was find all ID duplicates that had prices that weren't duplicates.

For example - the only rows I would be left with from the table above would be Product ID A134 because it has a duplicate ID and non duplicate prices.



The way I did it is below but I'm sure there must be an easier way.

Firstly I used Conditional formatting on the Product IDs to show the duplicates and deleted the none duplicates rows.
Next I sorted alphabetically and inserted a column to use CONCATENATE to join together the Product ID and the price.
I then used Conditional formatting to show the duplicates in the CONCATENATE results and deleted the none duplicate rows again.

This left me with the rows I needed.

Must be a much easier way?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
The last bit is incorrect - after the CONCATENATE formula I deleted the duplicates not the non duplicates.
 
Upvote 0
I do not understand. You wrote:
What I needed to do was find all ID duplicates that had prices that weren't duplicates.
What do you do if you have
PRODUCT ID PRICE
A123 1.66
A123 1.66
A123 1.22

DO you want to leave A123 or not? Note that it does have prices which are not duplicates (1.22 and 1.66), and it does have prices which are duplicates (1.66 and 1.66), at the same time.

J.Ty.
 
Upvote 0
Hi, thanks for the reply. In your example above I would need to keep all 3 rows with A123 if there were different values in the price column. (in an of the rows)

To add a bit more detail there is another column with a unique identifier.
The end result required is to keep just 1 row for each product but before that each different price needs examining to see which is correct.
 
Upvote 0
You may use the following formulas:

Excel 2010
ABCDE
1PRODUCT IDPRICEKeep?Unique IDNonunique ID
Unique PRICE
2A1231,66FALSEFALSETRUE
3A1231,66FALSEFALSETRUE
4A1341,22TRUEFALSEFALSE
5A1452,34FALSETRUEFALSE
6A1341,24TRUEFALSEFALSE
7A1671,26FALSETRUEFALSE
8A1291,67FALSETRUEFALSE

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=COUNTIFS($A$2:$A$8,A2,$B$2:$B$8,"<>"&B2)>0
D2=COUNTIF($A$2:$A$8,A2)=1
E2=NOT(OR(C2,D2))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>


After they are there, you can filter the data according to their values. Please let me know, if this satisfies your needs.

J.Ty.
 
Upvote 0
Is there any way to use just one formula to accomplish this?
Like an =INDEX(MATCH(INDEX()))?

Accomplish what?
As far as I understand, the originator wanted to be able to filter out rows with Id which have more than one price. Formula in C2 does it. The other two formulas are provided just in case.

J.Ty.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top