Search code examples
google-sheetsgoogle-sheets-formula

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


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.


Solution

  • 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")))