0

I'm trying out this nested IF function in google docs: =IF(AA2<0.2,0,IF(0.2<=AA2<0.4,1,IF(0.4<=AA2<0.6,2,IF(0.6<=AA2<0.8,2,IF(0.8<=AA2<=1,3,"WRONG")))))

However when the function is used on values such as 0.432, or 0.8, it automatically shows me the "WRONG" value. How can I correct this?

enter image description here

1 Answer 1

1

Your formula is syntactically correct, but there is a semantic issue: 0.2 <= AA2 < 0.4 will be evaluated as (0.2 <= AA2) < 0.4, i.e., false < 0.4 or true < 0.4. The end result is that the expression will always be evaluated as false.

The easiest way to make it work is probably to use ifs() instead of if(), like this:

=ifs( 
  AA2 < 0.2, 0, 
  AA2 < 0.4, 1, 
  AA2 < 0.6, 2, 
  AA2 < 0.8, 2, 
  AA2 <= 1, 3, 
  true, "WRONG" 
)
2
  • I see, thank you very much! This formula worked. Is ifs() basically better for nested functions compared to if()?
    – aislinx
    Commented May 20, 2021 at 10:13
  • 1
    In this use case, ifs() is easier to read and understand. Commented May 20, 2021 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.