简体   繁体   English

SUMPRODUCT 使用数组作为条件

[英]SUMPRODUCT using an array as a condition

I'm trying to create a function that sums the number of NO's in an array for multiple different names.我正在尝试创建一个 function ,它将多个不同名称的数组中 NO 的数量相加。 Basically the array looks like the image below and I want to sum all of the no's for the specified names.基本上该数组如下图所示,我想对指定名称的所有编号求和。 Breaking it into separate conditions is not an option because the list of names will be changing frequently.将其分解为单独的条件不是一种选择,因为名称列表会经常更改。

This is an example of what it looks like这是它的外观示例

My formula so far is =SUMPRODUCT(--(A1:A10=H2:H4),--(B1:E10="NO")) but it won't let me use an array as a condition.到目前为止,我的公式是=SUMPRODUCT(--(A1:A10=H2:H4),--(B1:E10="NO"))但它不允许我使用数组作为条件。 I've tried using COUNTIF as well, but it doesn't work with arrays of different sizes like I have.我也尝试过使用 COUNTIF,但它不适用于像我一样大小不同的 arrays。

Any help would be greatly appreciated.任何帮助将不胜感激。

Use MATCH and ISNUMBER:使用 MATCH 和 ISNUMBER:

=SUMPRODUCT(ISNUMBER(MATCH(A1:A10,H2:H4,0))*(B1:E10="NO"))

If you have O365 with the FILTER function, you could use:如果您有带有FILTER器 function 的 O365,您可以使用:

=SUM(N(FILTER(B1:E10,COUNTIF($H$2:$H$4,$A$1:$A$10))="NO"))

If you don't have that function, you can use:如果你没有那个 function,你可以使用:

=SUM(N(IF(COUNTIF($H$2:$H$4,$A$1:$A$10),$B$1:$E$10,"")="NO"))

or或者

=SUMPRODUCT(N(IF(COUNTIF($H$2:$H$4,$A$1:$A$10),$B$1:$E$10,"")="NO"))

Note the typo with regard to Keith vs Kieth .请注意有关Keith vs Kieth的错字。 If those are all spelled the same ( A4 , A7 , H3 ) the total would be 7 .如果这些都拼写相同( A4A7H3 ),总数将是7

在此处输入图像描述

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

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