ARRAYFORMULA VLOOKUP with ISBLANK in google sheets - google-sheets

I am trying to get a VLOOKUP to work on an entire column (minus the header), but I want blank entries if the column I am searching for is empty. I tried both these formulas, but to no avail (I still get the N/A in empty cells):
=ARRAYFORMULA(IF(ISBLANK(VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)),"",VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)))
=ARRAYFORMULA(IF(O2:O<>"",VLOOKUP(O2:O,Sheet1!B:C,2,FALSE)),"")
This is a slightly more complicated way than what I got working in another part of my sheet, which is the same without the VLOOKUP:
=ARRAYFORMULA(IF(ISBLANK(J2:J),"",J2:J))
Any ideas what am I doing wrong?

If you want to leave a blank instead of #N/A in a cell, you can use =IFERROR.
Like this:
=IFERROR(Your_formula, "value if the formula returns an error")
Since you are using ARRAYFORMULA, the iferror must be inside it
=ARRAYFORMULA(IFERROR(VLOOKUP(O2:O,Sheet1!B:C,2,FALSE),""))

Related

IFERROR() doesn't work and still return !REF#

I have a formula to import JSON into Google Sheets but in some scenarios, the requested fields do not exist and in such case I'd like the formula to return nothing instead of !REF#. In addition, I configured that if another specific cell in the same row is empty, the formula output will be blank either. I tried using =IFERROR((IF(ISBLANK(C5),"",ImportJSON("https://maps.googleapis.////com/maps/api/place/details/json?place_id="&C5&"&fields=opening_hours&language=iw&key=AI**********","/result/opening_hours/weekday_text", "noHeaders"))),"") but !REF# is returned anyway. What did I do wrong?

#REF! error in google sheets

I have a spread sheet which can be viewed at https://docs.google.com/spreadsheets/d/1bhIV1ULLXhjdSO_5Q5l5ZNe7Zaxrj15CYMW88FMFgRU/edit?usp=sharing
The way the spread sheet works is when a selection from the list is made the specific cells reference a data table and fills in the respective cells. This works perfectly in excel and I just use Iferror to hide the circular references. This is not the case in google sheets as the #REF! error still appears. How can I rectify so that they no longer appear? I have tried unique but it makes all the cells bank even when a different selection from the drop down box is made.
You can use the ISREF() function for this. Combine it with an IF() and you're good to go:
IF(ISREF('sheetname'!A4), 'sheetname'!A4, "")
The problem is that the formula itself is fine but (for column N) 'Attributes-InSeason-Trade_Mach'!$L121 and the following rows evaluate to "".
This means for INDEX in Google Spreadsheets that it will use all rows which in turn would overwrite the data in the next row because INDEX will be returning a range, not a single cell.
The Formula itself is evaluating fine, it does not cause an error which is why IFERROR does not trigger the alterantive "", the problem happens after the evaluation when it is trying to display the data.
You can just wrap the INDEX Call inside of an IF like this (This is an example for Column N)
=IFERROR(IF('Attributes-InSeason-Trade_Mach'!$L110 <> "",
INDEX('Attributes-InSeason-Trade_Mach'!$H$110:$I$214,
'Attributes-InSeason-Trade_Mach'!$L110,
COLUMNS(Trade_Machine!$P$4:P4)), ""), "")

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

Google spreadsheet Multiple result with VLOOK UP

The VLOOKUP formulas which works individually are
=if(VLOOKUP(E2,DB!$C:$E,1,0)>0,"COMPLETED",)
=if(VLOOKUP(E2,DB!$F:$H,1,0)>0,"IN PROGRESS",)
The issue is while displaying both results in a single cell, the formula which I came up for this was
C2=if(AND(VLOOKUP(E4,DB!$C:$E,1,0)>0),"COMPLETED",if(VLOOKUP(E4,DB!$F:$H,1,0)>0,"IN PROGRESS","UNDEFINED"))
I have tested the formula with normal conditions other than VLOOKUP and it works without any issues, not sure what's wrong with it.
Example : C10=if(AND(E10=1),"ONE",if(E10=2,"TWO","NO DATA"))
Any help appreciated.
May be its something simple but I am pulling my hair out for the last 3 hours.
Thanks :)
/-----------------------/
Updated 03.05.2016
Sorry for the comments that I have posted as I am new at using Stack overflow.
I have tried with only IF statements without any AND conditions, but the result is still same. The VLOOKUP is not returning the second value.
C15=IF(VLOOKUP(E15,DB!$F:$H,1,0)>0,"COMPLETED",if(VLOOKUP(E15,DB!$F:$H,1,0)>0,"IN PROGRESS","UNDEFINED"))
What I am expecting in cell C2 (sheet1) is check the values in cell
E2 against the columns C:H ( Sheet 2/ DB). If it belongs to
Column C:C in (sheet2/DB) then the value in C2 (sheet1) should display
as "Completed" else if the value is in column F:F ( sheet2/DB) then in C2
(sheet1) should display "In Progress".
Link to my spreadsheet link
There are a few problems with your formula.
VLOOKUP and similar functions search within a single row or column, and it seems like you're looking for your value in multiple rows and columns.
As #Meta mentioned, VLOOKUP returns N/A when the value is not found in the range, and you are expecting a zero or less value to be returned (when you check for >0 in the IF statement). Note that VLOOKUP returns the cell value itself and not an index of a match (like the MATCH function).
My suggestion is to replace your VLOOKUPs with COUNTIF.
=IF(COUNTIF(DB!$F:$H,E2)>0,"COMPLETED",IF(COUNTIF(DB!$C:$D,E2)>0,"IN PROGRESS","UNDEFINED"))
COUNTIF counts in multiple rows and columns, and will return a zero if no matches are found.

Make countif ignore "- -" from continue

I'm having trouble with a countif that I am using to count the number of entries in a range. The problem is that the range is populated with an array formula, and when the data changes the cells the array formula added a =CONTINUE(...) to now display -- (minus minus)
=COUNTIF(C6:C, "<>")
Is there a way that the countif could be written to ignore cells with --?
The -- is a way that Google Sheets displays the #VALUE! error. So you can use the IFERROR function to "mask" any of these errors:
=ArrayFormula(COUNTIF(IFERROR(C6:C);"<>"))
or more simply:
=ArrayFormula(COUNTA(IFERROR(C6:C)))
Updated:
Why don't you filter out all cells that are not text or similar to --?
Then use filtered range for countif.
=COUNTIF((ROWS(C6:C)-COUNTIF(C6:C"<>*")) , "ur criteria")
Is there a way your formula array could cast a string other than --?
Check this article
The search you are doing has regular expression.
Writing this on mobile. So please try out and pardon for weird formatting.

Resources