Nested IF error

Copper Contributor

Hi! I have a problem here I don't know how. The last if seems to be problematic. When I use IF 5 times its OK but when I add the last one it won't let me finish the formula. I'm assigning a value based on the string (a-c) and if the row is odd or even. I have a list of some values for example abcbaba and next to it the Q-P 5-7 table of values to assign. I don't know if it is enough info, I would have to remake the table (translate, remove sensible data...)

=IF(AND(C5="a";ISEVEN(ROW()));$Q$5;

IF(AND(C5="a";ISODD(ROW()));$P$5;

IF(AND(C5="b";ISEVEN(ROW()));$Q$6;

IF(AND(C5="b";ISODD(ROW()));$P$6;

IF(AND(C5="c";ISEVEN(ROW()));$Q$7;

IF(AND(C5="c";ISODD(ROW()));$P$7;"error"))))) (error here to let me know i wrote bad string value)

Thank you for your help

2 Replies

@momoos1_-650 

You're missing the last closing parenthesis:

 

=IF(AND(C5="a",ISEVEN(ROW())),$Q$5,IF(AND(C5="a",ISODD(ROW())),$P$5,IF(AND(C5="b",ISEVEN(ROW())),$Q$6,IF(AND(C5="b",ISODD(ROW())),$P$6,IF(AND(C5="c",ISEVEN(ROW())),$Q$7,IF(AND(C5="c",ISODD(ROW())),$P$7,"error"))))))

 

Here is a shorter version of the formula:

 

=IF(C5="a",IF(ISODD(ROW()),$P$5,$Q5),IF(C5="b",IF(ISODD(ROW()),$P$6,$Q$6),IF(C5="c",IF(ISODD(ROW()),$P$7,$Q$7),"error")))

@momoos1_-650 

As variant

=INDEX(
   $Q$5:$R$7,
   1*($C$5="a")+2*($C$5="b")+3*($C$5="c"),
   MOD(ROW(),2)+1)