具有两个以上“或”语句的Countifs

时间:2018-10-12 13:05:21

标签: excel

以下公式可以正常工作:

SUM(COUNTIFS(Data!$O:$O,">="&Leaderboard!I$202,Data!$O:$O,"<"&Leaderboard!J$202,Data!$DH:$DH,Leaderboard!$B203,Data!$HG:$HG,{"<>-","-","<>-"},Data!$HD:$HD,{"Q4 2018 Campaign","Q4 2018 Campaign",""}))

但是,我读到countifs()语句中有两个以上“或”数组语句会导致错误的结果,即。我不应该这样做:

SUM(COUNTIFS(Data!$O:$O,">="&Leaderboard!I$202,Data!$O:$O,"<"&Leaderboard!J$202,Data!$DH:$DH,Leaderboard!$B203,Data!$HG:$HG,{"<>-","-","<>-"},Data!$HD:$HD,{"Q4 2018 Campaign","Q4 2018 Campaign",""},Data!$HE:$HE,{"";">Data!$HF:$HF"}))

您能告诉我如何重新编写此公式以使其起作用吗?

目前我能想到的最好的方法是:

SUM(COUNTIFS(Data!$O:$O,">="&Leaderboard!I$202,Data!$O:$O,"<"&Leaderboard!J$202,Data!$DH:$DH,Leaderboard!$B203,Data!$HG:$HG,{"<>-","-","<>-"},Data!$HD:$HD,{"Q4 2018 Campaign","Q4 2018 Campaign",""},Data!$HE:$HE,""))
+
SUM(COUNTIFS(Data!$O:$O,">="&Leaderboard!I$202,Data!$O:$O,"<"&Leaderboard!J$202,Data!$DH:$DH,Leaderboard!$B203,Data!$HG:$HG,{"<>-","-","<>-"},Data!$HD:$HD,{"Q4 2018 Campaign","Q4 2018 Campaign",""},Data!$HE:$HE,">"&"Data!$HF:$HF))

1 个答案:

答案 0 :(得分:1)

您需要切换到SUMPRODUCT,尽管如此,我强烈建议您不要使用整个列引用。

=SUMPRODUCT((Data!O1:O100>=Leaderboard!I202)*(Data!O1:O100<Leaderboard!J202)*(Data!DH1:DH100=Leaderboard!B203)*((Data!HE1:HE100>Data!HF1:HF100)+(Data!HE1:HE100="")>0)*(Data!HG1:HG100={"<>-","-","<>-"})*(Data!HD1:HD100={"Q4 2018 Campaign","Q4 2018 Campaign",""}))

我删除了所有绝对引用(根据需要插入),并选择了上一行引用100(根据需要进行修改)。

致谢