Formula Help: Need to combine two CountIF's within a IF/AND Statement

Johnny Thunder

Well-known Member
Joined
Apr 9, 2010
Messages
693
Office Version
  1. 2016
Platform
  1. MacOS
Hi,

I am working with a formula that I am getting some weird results and hopin someone has a solution.

I have two Concatenate formulas that combine about 3 Columns of data, These formulas are in Col J:K.

I then have two other columns that individually look at each concatenate formula nand determine if the value row by row is unique or a duplicate using this: =IF(A3=15660010,IF(COUNTIF(J:J,J3)>1,"Duplicate","Unique"),"") and =IF(A3=15660010,IF(COUNTIF(K:K,K3)>1,"Duplicate","Unique"),"")

What I was hoping to do is delete both columns with the CountiF statement and just have a single column that does a look up to the Concatenate columns at the same time and says "If(AND( Both Columns have a unique value then flag as unique, if not flag as "Duplicate"

The basis of the formula seemed pretty straight forward so I wrote it but I am noticing that if Column J is a "Duplicate" and Column K is a "Unique" the formula returns "Unique" which is wrong, both would need to be unique values for the formula to return "Unique"

Any ideas of the issue?

Here is the formula: =IF(A3=15660010,IF(AND(COUNTIF(J:J,J3)>1,COUNTIF(K:K,K3)>1),"Duplicate","Unique"),"")
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try this:

=IF(A3=15660010,IF(AND(COUNTIF(J:K,J3)>1),"Duplicate","Unique"),"")
 
Upvote 0
Here is the formula: =IF(A3=15660010,IF(AND(COUNTIF(J:J,J3)>1,COUNTIF(K:K,K3)>1),"Duplicate","Unique"),"")
You need OR instead of AND

=IF(A3=15660010,IF(OR(COUNTIF(J:J,J3)>1,COUNTIF(K:K,K3)>1),"Duplicate","Unique"),"")

BTW, you should also amend your signature as those old HTML Makers do not work in the new forum software. See my signature for the similar alternative.
 
Upvote 0
Thanks for the help on the formula and the suggestion for the signature. I have updated. Thanks!
 
Upvote 0
You need OR instead of AND

=IF(A3=15660010,IF(OR(COUNTIF(J:J,J3)>1,COUNTIF(K:K,K3)>1),"Duplicate","Unique"),"")

BTW, you should also amend your signature as those old HTML Makers do not work in the new forum software. See my signature for the similar alternative.


Hi Peter, so when I tried the proposed solution with the change to "OR" I thought everything would be fine but I am encountering an issue where the formula is resulting in "Duplicate" even though the second statement on its own yields a "Unique" value?

I manually created formulas that were specific to 1 column and the first statement looking at Column J results in a "Duplicate" for a specific row, and the 2nd statement returns a "Unique" looking at the data in Column K but for some unknown reason it seems like the IF/OR statement is only looking at the 1st result since the formulas is returning a "Duplicate" as my result when it should be a "Unique"
 
Upvote 0
Here is the data that I was looking at,

Cell Formulas
RangeFormula
J77:J78, J79J77=A77&"_"&B77&"_"&ABS(H77)
K77:K78, K79K77=A77&"_"&B77&"_"&ABS(I77)
L77:L78, L79L77=IF(A77=15660010,IF(OR(COUNTIF(J:J,J77)>1,COUNTIF(K:K,K77)>1),"Duplicate","Unique"),"")
M79M79=IF(A79=15660010,IF(COUNTIF(K:K,K79)>1,"Duplicate","Unique"),"")
 
Upvote 0
I guess maybe issue is with cell absolute/relative references

Book1
ABCDEFGHIJKLM
1#1#2#3#4#5#6#7#8#9Concatenate 1st QtrConcatenate 2nd QtrCompareManual Formula (Col K)
215660010VFAKE0560114583314583315660010_VFAKE05601_14583315660010_VFAKE05601_145833Unique
315660010VFAKE0560114583314583315660010_VFAKE05601_14583315660010_VFAKE05601_145833Duplicate
415660010VFAKE05601014583315660010_VFAKE05601_015660010_VFAKE05601_145833Duplicate
515660010VFAKE0560208333315660010_VFAKE05602_015660010_VFAKE05602_83333UniqueUnique
Sheet4
Cell Formulas
RangeFormula
J2:J4, J5J2=A2&"_"&B2&"_"&ABS(H2)
K2:K4, K5K2=A2&"_"&B2&"_"&ABS(I2)
L2:L4, L5L2=IF(A2=15660010,IF(OR(COUNTIF($J$2:J2,J2)>1,COUNTIF($K$2:K2,K2)>1),"Duplicate","Unique"),"")
M5M5=IF(A5=15660010,IF(COUNTIF(K:K,K5)>1,"Duplicate","Unique"),"")
 
Upvote 0
Thank you for looking at this. I will give that a try and see if I run into any other issues.
 
Upvote 0

Forum statistics

Threads
1,223,943
Messages
6,175,547
Members
452,652
Latest member
eduedu

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