Comparing two columns containing grid refs to find duplicates.

squirrel31

New Member
Joined
Sep 15, 2014
Messages
30
Hello,

First off I'd like to point out that I originally had posted this query at the following link:- Comparing two columns containing grid refs to find duplicates. 5 days ago where I was unsucessful in gaining any replies that helped me out. (You will also find an attached example showing a snippet of my work so far)

As stated in the thread using the above link. I have a problem where I have in one column I have an ID, to the right I have Pos_X, to the right of that I have Pos_Y (Grid reference coords).

I have used a formula to find the duplicate IDs so that I could filter them out however I now need to analyse these duplicates further. Therefore I need to work out within the duplicate IDs which have duplicate grid references and which have unique grid references. Only the first of x amount of duplicate grid refs is then marked down in the Additional intersect? column using the format 'Y'. Any unique grid ref ID is also marked down as 'Y' in the Additional intersect? column.

Any scenario where a 'N' is marked would be the following:

  • The ID is not a duplicate therefore there is only one position for that ID.
  • There are multiple duplicate grid references and therefore the 2nd onwards are marked as N whilst the first is Y.

Any scenario where a 'Y' is marked are as follows:

  • There is a duplicate grid reference under the same ID which only the first duplicate grid ref is marked as Y
  • There are x amount of unique grid references under the same ID which all are marked as Y


Thanks in advance!
 
It seems that Unique can be determined with just:

=COUNTIFS(A$2:A2,A2,B$2:B2,B2,C$2:C2,C2)>1

In words, it's not the first occurrence of the ABC combination.
 
Last edited:
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Just realised that this formula is probably just lucky to be working to an extent. However, if i make two IDs the same and make both Pos_X and Pos_Y the same it still believes that it would be an additional intersect despite one only being the additional intersect and the other the one that can be ignored.

Formula: =IF(AND(L14="Y",N14="Y"),IF(COUNTIFS(J$14:J$14,J14,K$14:K$14,K14),IF(COUNTIF(I$14:I14,I14)>1,"Y","N"),"Y"),"N")

Problem:

[TABLE="width: 481"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Pos_X[/TD]
[TD]Pos_Y[/TD]
[TD]Intersect[/TD]
[TD]Duplicate[/TD]
[TD]Additional Intersect[/TD]
[/TR]
[TR]
[TD]363976725
[/TD]
[TD]167048
[/TD]
[TD]30311
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[/TR]
[TR]
[TD]363976725
[/TD]
[TD]167048
[/TD]
[TD]30311
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[TD]Y
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Use the Evaluate Formula tool to step through the formula. Is it working the way you want?

As an aside you have some unnecessary $ signs here (highlighted in red):

COUNTIFS(J$14:J$14,J14,K$14:K$14,K14)
 
Upvote 0
Using the evalutate formula tool the bits that appear to be working are when it looks to see if there is an intersect and whether its duplicte. However, it doesn't appear to be detecting whether the grid reference is the first occurance or not.
 
Upvote 0
Added the missing >1 however it did not change the outcome :/

Noticed if I make this change - =IF(AND(L16="Y",N16="Y"),IF(COUNTIFS(J$14:J16,J16,K$14:K16,K16),IF(COUNTIF(I$14:I16,I16)>1,"Y","N"),"N"),"N") I get this (Very very close to the outcome I want - In the Additional Intersect column I require the N's to be Y's and vice versa to achieve my expected results):
[TABLE="width: 535"]
<tbody>[TR]
[TD="colspan: 2, align: center"][/TD]
[TD="align: center"]ID[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Intersect[/TD]
[TD="align: center"]Duplicate?[/TD]
[TD="align: center"]Additional Intersect?[/TD]
[/TR]
[TR]
[TD="colspan: 2, align: center"]Duplicate 1 ->[/TD]
[TD="align: center"]363611789[/TD]
[TD="align: center"]166502[/TD]
[TD="align: center"]42025[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]N[/TD]
[/TR]
[TR]
[TD="colspan: 2, align: center"]Duplicate 2 ->[/TD]
[TD="align: center"]363976725[/TD]
[TD="align: center"]167048[/TD]
[TD="align: center"]30311[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]N[/TD]
[/TR]
[TR]
[TD="colspan: 2, align: center"]Duplicate 2.1 ->[/TD]
[TD="align: center"]363976725[/TD]
[TD="align: center"]167048[/TD]
[TD="align: center"]30311[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Y[/TD]
[/TR]
[TR]
[TD="colspan: 2, align: center"]Duplicate 2.2 ->[/TD]
[TD="align: center"]363976725[/TD]
[TD="align: center"]167080[/TD]
[TD="align: center"]167080[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]N[/TD]
[/TR]
</tbody><colgroup><col span="2"><col><col span="2"><col><col><col span="2"></colgroup>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,444
Messages
6,172,171
Members
452,445
Latest member
walkman99

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