将多个 "COUNTIF" 公式组合成一个语句

Combining multiple "COUNTIF" formula into one statement

情况:

我想搜索特定列的范围,以检查它是否包含多个特定字符串。如果找到选定的字符串,它将 returns 基于以下条件的字符串。

contain "#ERROR!" -> return "Partly Abnormal"

contain "#N/A" -> return "Abnormal"

contain "#N/A" and "#ERROR!" -> return "Abnormal"

No above strings -> return "Normal"

问题:

为此,我输入了以下公式,但我尝试了几个小时,仍然不知道如何将两者合二为一。非常感谢您的帮助,谢谢!

=IF(COUNTIF(A2:A,"#N/A"),"Abnormal","Normal")

=IF(COUNTIF(A2:A,"#ERROR!"),"Partly Abnormal","Normal")

使用IFS代替IF

这使您可以将多个条件合二为一。

注意:如果未找到指定的字符串,IFS 不允许指定默认条件,但您可以通过指定为最后一个条件 true 来使用 atrick 来做到这一点:

=IFS(COUNTIF(A2:A,"#N/A"),"Abnormal", COUNTIF(A2:A,"#ERROR!"),"Partly Abnormal", true, "Normal")

嵌套IF

=IF(COUNTIF(A2:A,"#N/A"), "Abnormal",
 IF(COUNTIF(A2:A,"#ERROR!"), "Partly Abnormal", "Normal"))