在数组函数中的 google 张 countif 中使用比较器

Using comparators in google sheets countif within an arrayfunction

我有一个表格公式,目前看起来像这样:

=ARRAYFORMULA(IF(ROW(J:J)=1,"eduProjects",IF($A:$A="",,
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&0)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&1)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&2)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&3)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&4)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&5)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&6)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&7)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&8)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&9)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&10)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&11)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&12)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&13)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&14)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&15)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&16)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&17)+
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&18))))

我试图通过使用比较器“<19”代替所有数字 0 到 18 来简化此操作

=ARRAYFORMULA(IF(ROW(L:L)=1,"eduProjects",IF($A:$A="",,
COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&"<19"))))

不幸的是,这在数组中似乎不起作用。我有什么想法可以简化这个公式吗?

你的公式:

COUNTIF(Projects!$B:$B&Projects!$R:$R&Projects!$S:$S,$A:$A&"Education"&"<19")
  • Countif() 条件基本上变成了 column A + Education + <19.
  • 的串联字符串

如果我的理解是正确的,Projects!$S:$S 应该包含一个数字值,因为您将它与 Projects!$B:$B & Projects!$R:$R 连接起来,并试图将它与 $A:$A&"Education"&0 连接的字符串进行比较值。

然后你可以使用COUNTIFS()来简化你的公式:

=ARRAYFORMULA(IF(ROW(L:L)=1,"eduProjects",IF($A:$A="",,
COUNTIFS(Projects!$B:$B&Projects!$R:$R,$A:$A&"Education",Projects!$S:$S,"<19"))))
  • 检查串联的 Projects!$B:$B & Projects!$R:$R 是否匹配串联的 $A:$A & "Education".
  • 检查 Projects!$S:$S 是否为 <19

输出:

B1 包含您的原始公式,而 E1 包含简化的公式)

(项目 Sheet)