Search code examples
google-sheetslambdagoogle-sheets-formula

Error Invalid call to non-function in google sheets


I have this Google Sheet file using this formula to split and flatten the input in B2:B3

=ArrayFormula(LAMBDA(sp, FLATTEN(SPLIT(sp, "♥"))))(BYROW(A2:A3, LAMBDA(rp, REPT(B2:B3&"♥",rp))))

I encounterd this error

Error
Invalid call to non-function.

enter image description here

What is it and How to solve it?


Solution

  • The error that you have received will mean that the formula was not able to call the parameter that your function was expecting, checking both of the 2 formulas that you have made:

    LAMBDA(sp, FLATTEN(SPLIT(sp, "♥")))
    And
    LAMBDA(rp, REPT(B2:B3&"♥",rp))
    

    Both of them are calling a range being this part of the formula expression however there is no really a valid value to be passed to the expression so it can "call it" to provide the result.

    In a nutshell, the error "Invalid call to a non function" means that in your formula you have put the call parentheses "()" which contains the data that will be called to the function that you have named but this data can't be called.

    An example of this error can be made with the following LAMBDA formula:

    =LAMBDA(test, test())(A1) 
    

    Using this formula will display the same exact error and this is due to the parameter being "called" it's invalid, this is due to the data being called a range and not a valid function.