Multiple Nested IF statements in MS Excel - brackets not right? -


i trying write statement following:

if r7 = "yes" , s7 = "yes" , t7 = "yes", output 1

if r7 = "yes" , s7 = "yes" , t7 = "no", output 2

if r7 = "yes" , s7 = "no" , t7 = "yes", output 3

if r7 = "yes" , s7 = "no" , t7 = "no", output 4

if else, output 5

i have written following statement:

=if(r7="yes",if(s7="yes",if(t7="yes",1),if(r7="yes",if(s7="yes",if(t7="no",2),if(r7="yes",if(s7="no",if(t7="yes",3),if(r7="yes",if(s7="no",if(t7="no",4)))))))),5) 

i know close however, issue when should display 4, displays “false” - have got brackets in wrong order?

any suggestions?

there's no need nest many if statements, can use and function.

=if(and(r7="yes",s7="yes",t7="yes"),1,if(and(r7="yes",s7="yes",t7="no"),2,if(and(r7="yes",s7="no",t7="yes"),3,if(and(r7="yes",s7="no",t7="no"),4,5)))) 

this should work you.

for further reading, see office documentation.


Comments