嵌套 If AND 语句 - google 张

Nested If AND statement - google sheets

我尝试编写的嵌套 if 语句不断返回错误,但我看不到哪里。我见过类似的主题,但 none 具有可行的语法。我试过使用和不使用 and 语句。非常简单地查看单元格 (C5) 中的值并根据 C5 中的数字返回相应的值。

=if(C5>84.5,1,if(and(C5<=84.5,C5>79.5,1.3,if(and(C5<=79.5,C5>74.5,1.7,if(and(C5<=74.5,C5>69.5,2,if(and(C5<=69.5,C5>64.5,2.3,if(and(C5<=64.5,C5>59.5,2.7,if(and(C5<=59.5,C5>54.5,3,if(and(C5<=54.5,C5>49.5,3.3,if(and(C5<=49.5,C5>44.5,3.7,if(and(C5<=44.5,C5>=40,4,if(C5<40,5))))))))))))))))))))

我希望输出范围为 1 到 5,具体取决于单元格 C5 中的值,但我不断收到以下错误

Wrong number of arguments to IF. Expected between 2 and 3 arguments, but got 1 argument

您系统地忘记关闭 and() 函数的括号。试试这个:

=if(C5>84.5,1,if(and(C5<=84.5,C5>79.5),1.3,if(and(C5<=79.5,C5>74.5),1.7,if(and(C5<=74.5,C5>69.5),2,if(and(C5<=69.5,C5>64.5),2.3,if(and(C5<=64.5,C5>59.5),2.7,if(and(C5<=59.5,C5>54.5),3,if(and(C5<=54.5,C5>49.5),3.3,if(and(C5<=49.5,C5>44.5),3.7,if(and(C5<=44.5,C5>=40),4,if(C5<40,5)))))))))))

如果你需要 ArrayFormula 使用:

=ARRAYFORMULA(
 IF( C5:C >  84.5, 1,
 IF((C5:C <= 84.5) * (C5:C >  79.5), 1.3,
 IF((C5:C <= 79.5) * (C5:C >  74.5), 1.7,
 IF((C5:C <= 74.5) * (C5:C >  69.5), 2,
 IF((C5:C <= 69.5) * (C5:C >  64.5), 2.3,
 IF((C5:C <= 64.5) * (C5:C >  59.5), 2.7,
 IF((C5:C <= 59.5) * (C5:C >  54.5), 3,
 IF((C5:C <= 54.5) * (C5:C >  49.5), 3.3,
 IF((C5:C <= 49.5) * (C5:C >  44.5), 3.7,
 IF((C5:C <= 44.5) * (C5:C >= 40),   4,
 IF( C5:C <  40, 5))))))))))))