[英]How do I get the count of non matching cells in a row between two sheets?
I have two sheets, Sheet A containing a truth table like such:我有两张工作表,工作表 A 包含这样的真值表:
A B C D E
Foo T F F T F
Bar T F F F F
Sheet B contains another table:表 B 包含另一个表:
A B C D E
T F F T F
I need to add a column to table A counting how many cells match the corresponding cell in sheet B, as such:我需要向表 A 添加一列,计算与工作表 B 中的相应单元格匹配的单元格数量,如下所示:
Foo T F F T F 2
Bar T F F F F 1
Best I could come up with for the first count cell was我能想到的第一个计数单元是
=COUNTIF(B2:F2,B2:F2=INDIRECT("sheet-b!A2:E2"))
but this gives me 0
even though it should be 2.但这给了我0
即使它应该是 2。
Edit: I was able to come up with this, which correctly counts the number of differing cells:编辑:我能够想出这个,它正确地计算了不同单元格的数量:
=SUM(ARRAYFORMULA(IF(B2:F2=INDIRECT("sheet-b!A2:E2"),1,0)))
The next thing I want is to add an AND statement, and count the cell if it matches or if the sheet-b
cell is F:我想要的下一件事是添加一个 AND 语句,并计算单元格是否匹配或如果sheet-b
单元格是 F:
=SUM(ARRAYFORMULA(IF(AND("F"=INDIRECT("sheet-b!A2:E2"),B5:F5=INDIRECT("sheet-b!A2:E2")),1,0)))
However it doesn't seem like i can use an AND statement in this formula.但是,我似乎无法在此公式中使用 AND 语句。 Even the following gives a sum of zero:甚至以下给出的总和为零:
=SUM(ARRAYFORMULA(IF(AND(TRUE,B2:F2=INDIRECT("sheet-b!A2:E2")),1,0)))
how come?怎么来的?
Edit2 : Link to example spreadsheet Edit2 : 链接到示例电子表格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.