如何在多条件COUNTIFS语句中连接多个范围查找?

时间:2017-06-27 16:59:52

标签: excel excel-formula

我建立了一个COUNTIFS声明,我已经计算了某些事情。我想在COUNTIFS语句中添加另一个参数。

目前正在运作的COUNTIFS:

=COUNTIFS('Fleet Maintenance Penetration'!$O$16:$O$1072,">="&DATEVALUE("5/1/2017"),'Fleet Maintenance Penetration'!$O$16:$O$1072,"<="&DATEVALUE("5/31/2017"),'Fleet Maintenance Penetration'!$N$16:$N$1072,"C",'Fleet Maintenance Penetration'!$C$16:$C$1072,"Abu Dhabi/Amiri Flight")

现在我想拿那个COUNTIFS并再添加一个参数。我正在寻找工作簿中某个范围内的某些值。 Range还引用了工作表&#34; Fleet Maintenance Penetration&#34;就像公式中的所有其他参考一样。

范围我想寻找一个价值让我们说&#34; P&#34;是R16:BH1072。我意识到我无法写出这样的代码:

=COUNTIFS('Fleet Maintenance Penetration'!$O$16:$O$1072,">="&DATEVALUE("5/1/2017"),'Fleet Maintenance Penetration'!$O$16:$O$1072,"<="&DATEVALUE("5/31/2017"),'Fleet Maintenance Penetration'!$N$16:$N$1072,"C",'Fleet Maintenance Penetration'!$C$16:$C$1072,"Air India",'Fleet Maintenance Penetration'!$R$16:$BH$1072,"P")

所以我能够通过添加仅1列的范围成功添加一个参数&#34; R&#34;。

=COUNTIFS('Fleet Maintenance Penetration'!$O$16:$O$1072,">="&DATEVALUE("5/1/2017"),'Fleet Maintenance Penetration'!$O$16:$O$1072,"<="&DATEVALUE("5/31/2017"),'Fleet Maintenance Penetration'!$N$16:$N$1072,"C",'Fleet Maintenance Penetration'!$C$16:$C$1072,"Air India",'Fleet Maintenance Penetration'!$R$16:$R$1072,"P")

如何在此公式中添加或连接其他列S-BH

1 个答案:

答案 0 :(得分:1)

COUNTIFS很棒,但遗憾的是规则和语法非常有限。一旦标准变得更加复杂,它就无法工作。另一方面,带有数组的SUMPRODUCT对于更复杂的标准来说是一种更灵活的解决方案。

您可以尝试以下公式:

=SUMPRODUCT(
('Fleet Maintenance Penetration'!$O$16:$O$1072 >=Date(2017,5,1))*
('Fleet Maintenance Penetration'!$O$16:$O$1072<=Date(2017,5,31))*
('Fleet Maintenance Penetration'!$N$16:$N$1072="C")*
('Fleet Maintenance Penetration'!$C$16:$C$1072="Air India")*
('Fleet Maintenance Penetration'!$R$16:$BH$1072="P"))

P.S。附加条件将尝试匹配同一行"P"中的任何R:BH。如果同一行中存在多个"P",则该行将被计算多次。