简体   繁体   中英

Excel - compare two columns

How to write IF statements in excel to compare two tables value?

for example,if have two tables T1, T2 and each having two fields P,Q and R,S.

T1:

P     Q 
-------
1     Yes
2     No
3     No
4     Yes
5     Yes

T2:

R     S 
--------
5     No
3     Yes
1     Yes
2     No
4     Yes

Let us consider the first row values of T1 & T2 we see above is A2 in excel spreadsheet. I want to write IF statement, If P & R values of A2 are equal then compare Q value of A2 with respect to the S value in T-2, and result P value in X field cell and result compared value in Y cell. Here the challenge is, S is not unique, so we need to use R value to find the S value. Result should be like as follows. If either Q or S is "Yes", the output value should be YES. If either Q and S is "No", the output value should be NO.

X     Y 
-------
1     Yes
2     No
3     Yes
4     Yes
5     Yes

Thanks in Advance.

REVISED:

If I understand you correctly, is this what you are trying to do:

=IF(COUNTIFS($A$2:$A$8,G2,$B$2:$B$8,"Yes")+COUNTIFS($D$2:$D$8,G2,$E$2:$E$8,"Yes"),"Yes","No")

What I did is to return "Yes" if count "Yes" is over or equal to 1. But let me know if I am missing anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM