Using VLOOKUP and IMPORTRANGE to find a match and return one of two potential values - if-statement

I am trying to change the value of cell B1 depending on if cell A1's value is found in another spreadsheet. If there is a match, I want the cell to say "banned". If A1 isn't found in the other spreadsheet, I want it to say "active'.
I've been playing around with this
=if((VLOOKUP(A3,IMPORTRANGE("https://docs.google.com/xyz","ALL BANNED ACCOUNTS!$G$2:$G$300"),1,false))=A3,"Banned","Active")
and can only get it to return "Banned". If there is no match, it always returns #N/A.
How can I remedy this?
Thanks!

Try changing "FALSE" TO "TRUE". I have found that VLOOKUP behaves erratically, and simply changing the [is_sorted] value helps.
Also, this may or may not make a difference, but you have an extra set of parentheses in your formula:
=if(VLOOKUP(A3,IMPORTRANGE("https://docs.google.com/xyz","ALL BANNED
ACCOUNTS!$G$2:$G$300"),1,false)=A3,"Banned","Active")

This is an old question, but in case it helps someone, since you are using VLOOKUP in one column, the only choices are that it equals A3, or that it isn't found, and if it isn't found, VLOOKUP fails, rather than equaling something else. Therefore, you can use this formula:
=iferror(if(VLOOKUP(A3,IMPORTRANGE("https://docs.google.com/xyz","ALL BANNED
ACCOUNTS!$G$2:$G$300"),1,false)=A3,"Banned","irrelevant"),"Active")
Note that "irrelevant" can be changed to anything, i.e. 0, etc. This result will never happen, as if VLOOKUP isn't equal to the search cell (in this case, A3), it will throw an error. So, "Active" as the result if there's an error will show rather than the value if VLOOKUP is false (since it can't be).
Hopefully this helps someone!

Related

Tableau Replacing Empty Values with 0

In Tableau I am struggling to replace a null/empty value with O. Tableau's ZN(expression) is still just returning a column with all the same empty/null values. Anything else I have tried to do has also been unsuccessful. Has anyone ever experienced this problem and was able to fix it.
Is it a numeric column where you're using ZN? You can also try using IFNULL() instead.

Google Sheets: How to create a nested IF statement with MATCH function?

I have been looking for a solution to this for quite a few hours, but unfortunately I appear to be stuck. I am trying to automatically input data based on another sheet with three possible options. DEADLINE, PMC or FMC, but it keeps crashing with if it can't find the first result. It will say #N/A, and tells me it can't find the first value. Why doesn't it check for the other values?
=IFS((MATCH(J8,Faults!F3:F9,0)),"DEADLINE",(MATCH(J6,Faults!F3:F9,0)),"PMC",(MATCH(J4,Faults!F3:F9,0)),"FMC")
Thanks in advance
MATCH does not return TRUE or FALSE. It either returns a number (the position within the range) or a #N/A error.
IFS will throw an error and stop processing just as a nested IF will. Wrap all the match functions in ISNUMBER to bypass thrown #N/A errors on no match.
=IFS(isnumber(MATCH(J8, Faults!F3:F9, 0)),"DEADLINE", isnumber(MATCH(J6, Faults!F3:F9, 0)), "PMC", isnumber(MATCH(J4, Faults!F3:F9, 0)), "FMC", true, "other")
I've added a default of Other if none of the three matches are found.

Nesting AND NOT ISBLANK with MULTIPLE IFs

I can't find an example close enough to this one on StackOverflow so here goes:
I want to return a message "Type?" if cell X is blank and cell Y has any text. But I'm trying to nestle it into an existing set of IFs.
Existing :
=IF($G241="Evo";M241*L241;IF($G241="Free";M241*L241;IF($G241="GN";M241*L241))))
Nestling this into the above:
=IF(AND(NOT(ISBLANK($J234));ISBLANK(G234));"Type?";"OK")
I tried this but it returns FALSE, maybe due to the AND I'm using, which I need since I'm creating a return based on two cells two cells.
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
getting Error:
AND expects boolean values. But 'Type?' is a text and cannot be coerced to a boolean.
IF(and(isblank(cell x),iferror(isstring(cell y),false)),"Type?","OK")
That should do it for you I think. you will need to replace cell x and cell y with the appropriate references. The iferror statement is there to catch what happens when evaluating a blank cell y.
The problem with this formula
=IF($G240="Evo";M240*L240;IF(AND(NOT(ISBLANK($J240));ISBLANK(G240);"Type?";"OK");IF($G240="Free";M240*L240;IF($G240="GN";M240*L240))))
is you are trying to check G240 for different values when it cant. Lets simplify your formula. We will replace your empty cell check with FORMULA 1
=If($G240="EVO", Do True Condition, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)
The problem is since you already did something (Formula 1) when G240 = "EVO", you cant start another check on what G240 after the fact with the way you have embedded your formula. a batter way of thinking of it is how to do a second check when G240="EVO" is false. Remember the general format of an if statement is:
IF(CONDITION,True Result, False Result)
There are only 3 things that go into an if statement. you tried putting in 3.
Try rearranging to this:
=If($G240="EVO", Do True Condition, IF(SOME CHECK to determine DO FOMULA 1 or CHECK for G240 = FREE, Do Formula 1, IF(G$240=Free, Do Free True Condition, Do Free False Condition)))
Basically break down what you want to check for in G240 and do it in sequence with your IF statement. Right now with what you have written, I cant tell how you want to determine if you want to run your formula 1 or if you want to check if G240="free" since you have two different outcomes if G240="Free"/
OK I think i found the issue. The IF(AND(NOT(ISBLANK works on it's own since there are no other IFs in the formula. I do want to test two different cells for text(letters) in order to show a warning if one cell was blank while the other not. But as soon as you insert the (AND into a string of multiple IFs it doesn't work.
Simply removing the (AND was all I needed to do. Another way to achieve a test for more than one blank cell was to simply add multiple IF(ISBLANKs.
EG: =IF(ISBLANK(A1)+IF(ISBLANK(A2)>2;condition true;condition false)
ForwardEd thanks very much for your help!
Regards

openoffice calc use contents of a cell as the formula for another

I searched for this and couldn't find how to do it. I have a cell that has an equation like: ".25 + .33" which I want displayed exactly like that. In the cell next to it, I want it to give me the result of that equation, ie, to turn that into "=.25 - .33" and show the result. I know I could do it the other way around, typing the formula out, and then using =FORMULA() and REPLACE() to remove the '=' or even use macros. But that's not what I want in this case. Is there a way to do this? I tried looking at functions like =INDIRECT() but no joy.
Given the constraints you have chosen, in a word, No.

IFERROR STATEMENT WITHIN VLOOKUP

I asked for help on another formula earlier which has lead to another head scratcher for me. I'm sure there is probably a way to use IFERROR somewhere in the formula below, but I can't seem to figure out where. I have a few columns returning #N/A that I just need to be blank.
Everything is working how it should except for the error. I have another formula feeding off of the results of this formula that I need to populate either Y or N based on the results. The #N/A is throwing some of them off.
=IF(J2="",VLOOKUP(B2,Sheet1!B:F,5,FALSE),"PICKED UP")
Just wrap it like this:
=IF(J2="",IFERROR(VLOOKUP(B2,Sheet1!B:F,5,0),"Error msg here"),"PICKED UP")
IFERROR will evaluate the first expression (here, it's the VLOOKUP) and if it returns an error, it will return the second part of the formula, which is Error msg here in this case. Change it to whatever you want to.
Also, you can use 0 to mean FALSE in excel (and 1 to mean TRUE).
=IF(J2="", IF(ISNA(VLOOKUP(B2,Sheet1!B:F,5,FALSE)), "", VLOOKUP(B2,Sheet1!B:F,5,FALSE)),"PICKED UP")