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.
What is it and How to solve it?
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.
You can try this formula for lambda approach.
=LAMBDA(Rpt,Rpn,QUERY(INDEX(FLATTEN(SPLIT(REPT(Rpt&"♥",Rpn),"♥"))),"where Col1 is not null"))(B2:B3,A2:A3)
Without lambda-
=QUERY(INDEX(FLATTEN(SPLIT(REPT(B2:B3&"♥",A2:A3),"♥"))),"where Col1 is not null")
I think the issue is that you are calling a vertical range B2:B3 from within the internal LAMBDA that is not defined as part of the range to be passed to it from the BYROW that is calling it. I think a MAP would be more appropriate than the BYROW in this case as you can then feed multiple ranges into the LAMBDA it calls:
=arrayformula(lambda(flt,filter(flt,flt<>""))(lambda(sp,flatten(split(sp,"|")))(map(A2:A3,B2:B3,lambda(a,b,rept(b&"|",a))))))
N.B. - The additional outer lambda is required to filter out the empty cells that will occur when sp is flattened if the numbers of repeats in B2:B3 is not the same (as jagged arrays aren't allowed). This could obviously also be done with a QUERY, but here is one way of doing it with LAMBDAs all the way through.
Related
Values in column A
/teams/brazil/esporte-clube-vitoria/306/
/teams/brazil/gremio-esportivo-brasil/6205/
Expected values:
esporte-clube-vitoria
gremio-esportivo-brasil
Formula that I currently use but that generates errors when used with ARRAYFORMULA for various values:
=ARRAYFORMULA(IFERROR(TRIM(MID(SUBSTITUTE(A1:A,"/",REPT(" ",99)),299,99))))
Is there a more reliable formula for this job?
You can try the following formula
=ArrayFormula(REGEXREPLACE(R1:R,"/\w+/\w+/|[0-9]|/",""))
Formula that I currently use but that generates errors when used with ARRAYFORMULA for various values
Cannot test if this formula works for other values unless you share them.
One could also use
=ArrayFormula(INDEX(SPLIT(R2:R,"/"),,3))
I have a formula which is a combination of vlookup(),lookup() and indirect() functions:
=IFERROR(VLOOKUP(C3,INDIRECT(LOOKUP("x",AD3:AH3,$AD$1:$AH$1)&"!"&"$D$3:$AB$325",TRUE),24,FALSE),"")
I need to convert this formula in a way that it is an arrayformula(). I have done the following:
=ARRAYFORMULA(IFERROR(VLOOKUP(C3:C,INDIRECT(LOOKUP("x",{(AD3:AD),(AH3,AH}), $AD$1:$AH$1) &"!"&"$D$3:$AB$325",TRUE),24,FALSE),""))
But, I am always getting an error with lookup part, which mentiones that "lookup evaluates out of range". Any suggestions, where could be an error?
I have a spreadsheet which I need to import several data from other spreadsheets, So I have =importrange(<theOtherFile>,<cell>) in different places. But I have to go, one by one allowing access the first time my file is created.
What I want is to have an a different sheet a list with all the document references I link in the document. Over there, there is a list of all documents including Google Docs and Google Presentations. Then a script creates a =importrange() for each of them so I can, in one shot, press "Allow Access" once for each file (and the needed values pop up in the other places).
The problem is that in this huge list of importranges, I cannot tell apart #REF errors because I still don't have permission to collect data from the file or because the file is not a spreadsheet at all ("Spreadsheet cannot be found." error).
So, my question is: can I, beforehand, tell apart Google Sheets from other types of files so my script doesn't try to import them? If not; Can I somehow interact with the error message of a #REF error (this way I could write a formula that cleans the cell if the importrange() failed because the file is not a spreadsheet at all)?
=ERROR.TYPE(A1)
#NULL! 1
#DIV/0! 2
#VALUE! 3
#REF! 4
#NAME? 5
#NUM! 6
#N/A 7
#ERROR! 8
(no error) #N/A
if a cell has no error, the ERROR.TYPE gives an error. Use:
=IFERROR(ERROR.TYPE(B11);"No error")
Google Sheets offers only two functions to nullify the errors:
IFERROR - Returns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.
IFNA - Returns the first argument if it is not an #N/A error value, otherwise returns the second argument if present, or a blank if the second argument is absent.
to analyze the error you can use:
ERROR.TYPE - Returns a number corresponding to the error value in a different cell.
ISREF - Checks whether a value is a valid cell reference.
ISNA - Checks whether a value is the error #N/A.
ISERR - Checks whether a value is an error other than #N/A
ISERROR - Checks whether a value is an error.
I have a Google Sheet (example) with a basic vlookup to create a summable column. It returns "#N/A" for every search key not found, and attaches the following error to those cells:
Error Did not find value 'me#me.com' in VLOOKUP evaluation.
After much searching the only solution I found was to wrap the vlookup in an IF(ISNA()), given in How to link various Google spreadsheets using IMPORTRANGEs that contain VLOOKUP formulas without getting #N/A returned?. This works, but it really seems like I should not have to do this. Is there another way?
Update 2019-03-01: The best solution is now =IFNA(VLOOKUP(…), 0). See this other answer.
You can use the following formula. It will replace any #N/A value possibly returned by VLOOKUP(…) with 0.
=SUMIF(VLOOKUP(…),"<>#N/A")
How it works: This uses SUMIF() with only one value VLOOKUP(…) to sum up. So the result is that one value, but only if unequal to #N/A as per the condition argument. If the value equals #N/A however, the sum is zero. That's just how SUMIF() works: if no values match the conditions, it returns 0, not NULL, not #N/A.
Advantages:
Compared to the solution =IF(ISNA(VLOOKUP(…)),"",VLOOKUP(…)) referenced in the question, this solution contains the VLOOKUP(…) part only once. This makes the formula shorter and simpler, and avoids the mistakes that happen when editing only one of the two VLOOKUP(…) parts.
Compared to the solution =IFERROR(VLOOKUP(…)) from the other answer, errors are not suppressed as that would make detecting and debugging them more difficult. Only #N/A values are suppressed.
=IFNA(VLOOKUP(...), "")
Not sure if this has changed recently, but the IFNA implementation supports a single listing of the VLOOKUP now. That is, you don't have to wrap it in another IF.
An advantage there is that you could choose "", 0, NULL, etc. as the value to show on failure.
A simpler way to suppress error messages - of any kind - is to use the iferror wrapper:
=iferror(vlookup(A1,Lookup!A:B,2,FALSE))
I don't think there can be an easier way than that. By design, vlookup should not simply return blank if the key wasn't found: this would be indistinguishable from the situation where the key was found but the corresponding entry in second column was blank. Some error has to be thrown, and then it's up to the spreadsheet user how to handle it.
Just add
TRUE, ""
to your list of parameters, like so:
IFS(condition1, value1, condition2, value2, TRUE, "")
This works, because IFS "returns a value that corresponds to the FIRST true condition."
I am attempting to create Index and Match functions inside an "IF" Function. Generally this should be an easy task except I have more than two tables that need to be indexed as the value can be in any one of three.
I have written a formula and kept getting a match in one column but it kept prompting me to change the first If to display a boolean and that I cannot coerce the value to be a boolean. The other attempt worked and displayed the value but created a #N/A! to the right of the cell with the formula:
=if(A2="AP",index(FAC!$A$2:$A$45,match(A2,FAC!$E$2:$E$45)),{index(BC!$A$2:$A$45,match(A2,BC!$E$2:$E$45,0)),index(MFC!$A$2:$A$45,match(A2,MFC!$E$2:$E$45,0))})
In addition to pnuts' nested IFERROR solution (which will work), the array concatenation method should work with:
=IF(A2="AP",INDEX({FAC!$A$2:$A$45;BC!$A$2:$A$45;MFC!$A$2:$A$45},MATCH(A2,{FAC!$E$2:$E$45;BC!$E$2:$E$45;MFC!$E$2:$E$45},0)),)
or perhaps just
=IF(A2="AP",QUERY({FAC!$A$2:$E$45;BC!$A$2:$E$45;MFC!$A$2:$E$45},"select Col1 where Col5 = '"&A2&"' limit 1",0),)