ARRAYFORMULA() with LOOKUP - google-sheets

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?

Related

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.
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.

Google spreadsheet -- how do I sum up my wages in this spreadsheet?

I am trying to calculate my earnings on a Google Spreadsheet but have no idea what I am doing. I got this far with spreadsheets, but VLOOKUP returns a #N/A error and I can't calculate the sum in column B5. What am I doing wrong? Here's my spreadsheet:
https://docs.google.com/spreadsheets/d/1bsbQ4_0cITvdTqWWdX-Et1fiTL9Qw3WD_aminlpqgwY/edit?usp=sharing
The error message #N/A is caused by the VLOOKUP operation in cell D9. It is looking up cell C9, which is blank. There must be a value in a VLOOKUP operation. If you want to make this message go away, either put a value into C9 or use the IFERROR function. This only gives a value if the output is not an error. In cell D9, you can put this formula:
=IFERROR(VLOOKUP(C9,$C$2:$D$5,2,FALSE)). This should return nothing if there is an error.

Search for string with VLOOKUP in Google Sheets

Trying to find a particular string in a google sheet column (column A) and return the value of the cell directly to the right (column B). If tried the following, but keep getting a Formula parse error. Please advise:
=VLOOKUP(“Assessment Guide - AWG”, A16:B120,2,FALSE)
That formula looks right to me, but if you could take a screenshot of how you wrote the formula that would be helpful. Usually formula parsing issues happen when you use a semicolon instead of a comma or have an extra parenthesis or a quote in the wrong place.

Suppress #N/A returned by Google Sheets vlookup

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."

What am I doing wrong with gspreadsheets' vlookup formula?

In google spreadsheets, I have the formula:
=VLOOKUP("hello",'Sheet1'!$C$2:$C$65, 1)
My expectation is that this would echo the value "hello" if it was found in Sheet1 in range C2:C65, and be null otherwise. It instead gives the value from C35 ("hello" is found in C17 of Sheet1).
Does anyone know what I'm doing wrong this?
Thanks!
VLOOKUP returns #N/A where the formula is correct but the value sought is not present where searched for.
The fourth parameter for the function is optional but defaults to TRUE which may give incorrect results when the search column is not sorted.
Ref
I think what you are doing wrong is 'instructing' the formula that the column to be searched is sorted in order when it is not. Sorting is critical for a binary search.
If you interpret How to match info between tabs in a Google spreadsheet the same way as I did there is an example that works on Web Apps.

Resources