简体   繁体   English

如何获取两张工作表之间一行中不匹配单元格的数量?

[英]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链接到示例电子表格

how do I get the count of non-matching cells in a row between two sheets如何在两张纸之间的一行中获取不匹配单元格的计数

 =ARRAYFORMULA(IF(LEN(A2:A), 
 MMULT(IF(B2:F='sheet-b'!A2:E2, 0, 1), TRANSPOSE(COLUMN(B2:F2)^0)), ))

0

try:尝试:

=ARRAYFORMULA(IF(A1:A<>"", COUNTIFS(TRIM(
 TRANSPOSE(QUERY(TRANSPOSE(Sheet2!J1:N),,999^99))),
 TRANSPOSE(QUERY(TRANSPOSE(B1:F)       ,,999^99))), ))

0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在表格中为一行中的非空白单元格收集数据和标题 - How to collect data and headers for non blank cells in a row in Sheets 是否可以计算Google表格中的空白单元格,但仅当它们位于具有值的单元格之间时才可以计数? - Is there a way to count blank cells, but only if they are between cells with values, in Google Sheets? 如何为Google表格中的两个单元格之间的if语句创建公式 - How can I create a formula for if statements between 2 cells in google sheets 如何依次填充Google表格中的大量单元格? - How do I sequentially fill a big range of cells in Google Sheets? 如何使用跳过的行在 Google 表格中保持运行计数? - How do I keep a running count in Google Sheets with skipped lines? 如何比较谷歌表格中的两个公式(计算)单元格 - How to compare two formula (calculated) cells in Google Sheets 如何让此代码仅复制符合我的对象匹配条件的行? 目前如果复制每一行 - How do i get this code to copy only the rows that match my object matching criteria? currently if copies every row 如果vlookup与Google表格中的其他两个单元格匹配,如何减去两个单元格的值 - How to subtract the value of two cells if vlookup matches on two other cells in Google Sheets Arrayformula仅在两个单元格都不为零/非空白时才计算一行中的单元格少于另一行中的单元格 - Arrayformula count how many cells in a row are less than cells in another row only if both are nonzero/nonblank 如果一行上的两个单元格都相等,如何为行着色 - How to color row if two cells on a row both equal complete
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM