Formula based on data in 2 column

Chandresh

Board Regular
Joined
Jul 21, 2009
Messages
146
HI ALL,

Could you please help me with formula which can give me result based on data from 2 different column.

[TABLE="width: 128"]
<tbody>[TR]
[TD="width: 64, bgcolor: transparent"]ID[/TD]
[TD="width: 64, bgcolor: transparent"]Type[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A500[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A500[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A501[/TD]
[TD="bgcolor: transparent"]P[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A501[/TD]
[TD="bgcolor: transparent"]P[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]P[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]P[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A506[/TD]
[TD="bgcolor: transparent"]S[/TD]
[/TR]
</tbody>[/TABLE]

I have data in 2 columns A and B, I need a formula which can lookup the data in entire column and provide me the results.

- if data against ID is "S" then "OK"
- if data against ID is "P. then "OK"
- if the data against ID is "S" and "P" then "Check" - (ID A506 has both P and S)

Thanks
Chandresh
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Would this work? You would need to adjust the ranges to match your data but:

=IF(SUM(IF(COUNTIFS(A1:A10, A12, B1:B10, "S")>1, 1, 0)+IF(COUNTIFS(A1:A10, A12, B1:B10, "P")>1, 1, 0))=2, "CHECK", "OK")

Where:
A1:A10 is the range of ID
B1:B10 is the range of Type
A12 is the ID you are looking up
 
Upvote 0
Would this work? You would need to adjust the ranges to match your data but:

=IF(SUM(IF(COUNTIFS(A1:A10, A12, B1:B10, "S")>1, 1, 0)+IF(COUNTIFS(A1:A10, A12, B1:B10, "P")>1, 1, 0))=2, "CHECK", "OK")

Where:
A1:A10 is the range of ID
B1:B10 is the range of Type
A12 is the ID you are looking up


Thanks for your reply , I have applied the formula in my working sheet however its working for some cases. I have added one more id "A501" in the data base now the output comes as "OK".
Ideally it should come as "Check" as there are 2"P" and 1 "S", could you please help.

[TABLE="width: 265"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]ID[/TD]
[TD]Type[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A500[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A500[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]P[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]P[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]P[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]P[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks
chandresh
 
Upvote 0
Thanks for your reply , I have applied the formula in my working sheet however its working for some cases. I have added one more id "A501" in the data base now the output comes as "OK".
Ideally it should come as "Check" as there are 2"P" and 1 "S", could you please help.

[TABLE="width: 265"]
<tbody>[TR]
[TD]ID[/TD]
[TD]Type[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A500[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A500[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]P[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]P[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A501[/TD]
[TD]S[/TD]
[TD]OK[/TD]
[TD]output should be Check[/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]P[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]P[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A506[/TD]
[TD]S[/TD]
[TD]CHECK[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks
chandresh

Ah my bad i think i just missed off the = sign where the > signs are:

The corrected formula below:

=IF(SUM(IF(COUNTIFS(A1:A10, A12, B1:B10, "S")>=1, 1, 0)+IF(COUNTIFS(A1:A10, A12, B1:B10, "P")>=1, 1, 0))=2, "CHECK", "OK")

(If you have already adjusted to your range, then you can just add the = sign in the 2 places in red.)
 
Upvote 0
are you sure that rows are correct? in row 2
=IF(COUNTIFS(A:A, A2, B:B, "S")>1, 1, 0)+IF(COUNTIFS(A:A, A2, B:B, "P")>1, 1, 0)
1 ok
2 check
0 not found
 
Upvote 0
Hi,

A little simpler:


Book1
ABC
1IDType
2A500SOK
3A500SOK
4A501PCHECK
5A501PCHECK
6A501SCHECK
7A506PCHECK
8A506PCHECK
9A506SCHECK
10A506SCHECK
11A506SCHECK
12A506SCHECK
Sheet161
Cell Formulas
RangeFormula
C2=IF(AND(COUNTIFS(A$2:A$12,A2,B$2:B$12,"S"),COUNTIFS(A$2:A$12,A2,B$2:B$12,"P")),"CHECK","OK")


Formula copied down.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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