简体   繁体   English

Excel嵌套IF语句出现问题

[英]Excel Nested IF Statement Trouble

=IF(J4 >= 20, A, IF(J4 < 20 AND J4 > 13, B, IF(J4 < 14 AND J4 > 8, C, IF(J4 < 8, D,0)))) = IF(J4> = 20,A,IF(J4 <20 AND J4> 13,B,IF(J4 <14 AND J4> 8,C,IF(J4 <8,D,0)))))

The numeric values = points The values A - D is a scoring systems that rates a person based upon their points and gives them a value from AD. 数值=点值A-D是一个评分系统,该系统根据某人的得分为他们评分,并根据AD给他们一个值。

I've been stuck on this formula for a long time and have no idea what I'm doing wrong, all help would be appretiated! 我一直坚持这个公式很久了,不知道我在做什么错,所有帮助将不胜感激!

You may consider to update your statement as follows. 您可以考虑如下更新您的声明。

=IF(J4<8,"D",IF(J4<14,"C",IF(J4<20,"B","A")))

You can see that it's important in this case to move in one direction, either low to high , or high to low . 您会看到在这种情况下,向或从高至低的一个方向移动很重要。 This allows us to return a result whenever a test returns TRUE, because we know that the previous tests have returned FALSE. 这使我们可以在测试返回TRUE时返回结果,因为我们知道以前的测试已经返回FALSE。

尝试这个:

=IF(J4 >= 20, "A", IF(J4 > 13, "B", IF(J4 > 8, "C", "D")))

这是一个公式:

=IF(20<=J4,"A",IF(13<=J4,"B",IF(8<=J4,"C",IF(J4<8,"D",0))))

I think the syntax you're using for the AND function is wrong. 我认为您用于AND函数的语法是错误的。 You need to nest all the parameters you want to use within the AND function. 您需要在AND函数中嵌套要使用的所有参数。 like this: 像这样:

=IF(AND(J4<20,J4>8),"true","false")

Another apporach assuming that the possible inputs in J4 are integers below 1000: 另一个方法假设J4中的可能输入是小于1000的整数:

=IFERROR(INDEX({"A";"B";"C";"D"},MATCH(J4,{1000;19;12;7},-1)),0)

I think this one is easier to read and to maintain. 我认为该代码更易于阅读和维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM