简体   繁体   中英

Excel: Compare count number of rows in which two columns have same text that is NOT a particular value

I have two columns each of which contains strings; sometimes the cell is empty.

I need a count of how many times the two columns have the same value, but NOT blank and NOT one particular value ("HR-L" must be excluded).

For example:

U1        R1

D-SW      D-SW
SH-N      SH-N
D-NE      SH-S
(blank)   (blank)
(blank)   P-NE
HR-L      HR-L

Should return 2, because in rows 1 and 2 the cells are identical and both "acceptable" answers. In row 4, I don't want to count when they are identical because they're both blank. In row 6, I don't want count when they're identical because they're both HR-L.

I tried:

=COUNTIFS(Table1[1U],"<>",Table1[1U],"<>HR-L", Table1[1U], Table1[1R])

But that is resolving Table1[1R] to one particular value and comparing each row of 1U to that particular value, rather than comparing Columns 1U and 1R within each row.

您无法使用COUNTIFS执行此操作,因为COUNTIFS不允许您在两列之间进行直接比较-您可以像这样使用SUMPRODUCT

=SUMPRODUCT((A1:A10=B1:B10)*(A1:A10<>"")*(A1:A10<>"HR-L"))

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