Home > Mobile >  ERROR Wrong number of arguments to IF. Expected between 2 and 3 arguments, but got 4 arguments
ERROR Wrong number of arguments to IF. Expected between 2 and 3 arguments, but got 4 arguments

Time:11-12

I'm trying to create logic but return #N/A as mentioned in the title, what did I do wrong?

=IF(AND(I4=B4,I4=B5,I4=B6),CONCATENATE(B4,";",B5,";",D6),IF(AND(I4=B4,I4=B5),CONCATENATE(D4,";",D5)),IF(I4=B4,D4)), but got error.

CodePudding user response:

You have an extra closing parenthesis after the second Concatenate formula. You're missing to a final scenario when I4 differs from B4, it'll just return FALSE, you can add an extra comma after D4 and specify what you want it to return:

=IF(AND(I4=B4,I4=B5,I4=B6),CONCATENATE(B4,";",B5,";",D6),IF(AND(I4=B4,I4=B5),CONCATENATE(D4,";",D5),IF(I4=B4,D4,"I4 and B4 are different")))

CodePudding user response:

use:

=IF(AND(I4=B4,I4=B5,I4=B6), B4&";"&B5&";"&D6, 
 IF(AND(I4=B4,I4=B5), D4&";"&D5, IF(I4=B4, D4, )))
  • Related