Why does this report #Value error in Excel - excel

Just trying to report binary test...
=IF(FIND("RHS",B14),"RHS","LHS")
The function works for RHS, but reports #value for LHS. Why?

The FIND function returns the index of a string within another string, however, if the string you are looking for is not there it results in an error and displays "#value".
Likewise the if function is expecting an expression that results in a true or false value like: if ( this expression =true, then do this , otherwise do this)
Since the find function returns an error #value, it causes the if statement to also error out, when trying to calculate what to do.
To mitigate this you can wrap the function with either an ISNUMBER OR ISERROR function to validate if the find function is indeed returning an expected result
=IF(ISNUMBER(FIND("RHS",B14)),"RHS","LHS")
=IF(ISERROR(FIND("RHS",B14)),"LHS","RHS")

If expects a boolean result.
Find returns i9f it finds sowethig a number if Not showws an error that is why RDS works
A ISNUMBER returns suich a boolean result, that is needed
=IF(ISNUMBER(FIND("RHS",B14)),"RHS","LHS")

Related

Why am I getting a value error in excel while using the ifs function?

=IFS(SEARCH("C*",A9),"Cake",SEARCH("K*",A9),"Cookies",SEARCH("B*",A9),"Bread & Bun",SEARCH("Y*",A9),"Pastry")
It works for the first criteria and returns "cake" but won't work for the others. I keep getting a #VALUE error.
Can help please??
SEARCH isn't a Boolean-valued function. It doesn't return FALSE if the string isn't found -- it returns a #VALUE! error which isn't coerced to FALSE.
What you could do is wrap everything like SEARCH("C*",A9) with ISNUMBER(): ISNUMBER(SEARCH("C*",A9)) since Excel can tell that #VALUE! isn't a number.

invalid input syntax for type numeric: " "

I'm getting this message in Redshift: invalid input syntax for type numeric: " " , even after trying to implement the advice found in SO.
I am trying to convert text to number.
In my inner join, I try to make sure that the text being processed is first converted to null when there is an empty string, like so:
nullif(trim(atl.original_pricev::text),'') as original_price
... I noticed from a related post on coalesce that you have to convert the value to text before you can try and nullif it.
Then in the outer join, I test to see that there's a limited set of acceptable characters and if this test is met I try to do the to_number conversion:
,case
when regexp_instr(trim(atl.original_price),'[^0-9.$,]')=0
then to_number(atl.original_price,'FM999999999D00')
else null
end as original_price2
At this point I get the above error and unfortunately I can't see the details in datagrip to get the offending value.
So my questions are:
I notice that there is an empty space in my error message:
invalid input syntax for type numeric: " " . Does this error have the exact same meaning as
invalid input syntax for type numeric:'' which is what I see in similar posts??
Of course: what am I doing wrong?
Thanks!
It's hard to know for sure without some data and the complete code to try and reproduce the example, but as some have mentioned in the comments the most likely cause is the to_number() function you are using.
In the earlier code fragment you are converting original_price to text (string) and then substituting an empty string ('') if the value is NULL. Calling the to_number() function on an empty string will give you the error described.
Without the full SQL statement it's not clear why you're putting the nullif() function around the original_price in the "inner join" or how whether the CASE statement is really in an outer join clause or one of the columns returned by the query. However you could perhaps alter the nullif() to substitute a value that can be converted to a number e.g. '0.00' instead of ''.
Sorry I couldn't share real data. I spent the weekend testing small sets to try and trap the error. I found that the error was caused by the input string having no numbers, which is permitted by my regex filter:
when regexp_instr(trim(atl.original_price),'[^0-9.$,]') .
I wrongly expected that a non numeric string like "$" would evaluate to NULL and then the to_number function would = NULL . But from experimenting it seems that it needs at least one number somewhere in the string. Otherwise it reduces the string argument to an empty string prior to running the to_number formatting and chokes.
For example select to_number(trim('$1'::text),'FM999999999999D00') will evaluate to 1 but select to_number(trim('$A'::text),'FM999999999999D00') will throw the empty string error.
My fix was to add an additional regex to my initial filter:
and regexp_instr(atl.original_price2,'[0-9]')>0 .
This ensures that at least one number will be in the string and after that the empty string error went away.
Hope my learning experience helps someone else.

Application.Check spelling not returning correct Boolean value

I am trying to prepare a excel file which automatically shows if any word is misspelled. There are codes that shows and highlights the particular word field when word is misspelled ,however I want to highlight a different cell if any
of the words are misspelled.
This is what I did:-
Function GFD() As Boolean
Application.CheckSpelling (Range("a1").Text)
End Function
'=======================================================
Function GFF() As Boolean
Application.CheckSpelling (Range("a2").Text)
End Function
Problem is in the function I am not getting correct value, if I write "asdfsd" in a2 the function is set as False ,which is correct. But if I write "perfect" which is correct, it again returns False.
Please help.
You have to set the function to the value returned by the application:
Function GFD() As Boolean
GFD = Application.CheckSpelling(Range("a1").Text)
End Function

How can I nest an vector index match function in an if statement? (Excel)

I have the following vector function:
{=INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0))}
This function returns what is in Key!$K$2:$K$25 if V5 is a match. This formula works. I would like to also make the function return, "Not Found", if the value searched for is not present in Key!$K$2:$K$25. I have tried the following, but it doesn't work. Could someone help?
{=IF(MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V3)),0),INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V3)),0)),"Not Found")}
Thanks.
simply merge your =INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0)) with IFERROR
=IFERROR(INDEX(Key!$K$2:$K$25,MATCH(TRUE,ISNUMBER(SEARCH(Key!$K$2:$K$25,V5)),0)),"Not found")

IF, OR and IFERROR function in excel

Column_A Column_B New (Expecting result for this situation)
#N/A #N/A Manual Posting
My function has problem for the last syntax"IFERROR(IFERROR(....)" . Currently, I get #N/A for the "New" column. However, I want to get "Manual Posting" instead.
My syntax:
=IF(OR(IFERROR(B1,A1)="Bank BPH",IFERROR(B1,A1)="GE Budapest Bank"),"GECapital",IF(IFERROR(B1,A1)="Avio Aero","GE Aviation",IFERROR(IFERROR(B1,A1),"Manual Posting")))
Ok, working it out I think I can explain.
IFERROR(x,y) returns value x, unless it's an error, then it returns y .. (even if it is an error).
You then take result of that, and compare it to a string:
IFERROR(A1,B1)="Bank BPH"
Assuming valid values, that expression will, of course, return TRUE or FALSE.
If both A1 and B1 are error, however, what happens ??
What is the result of:
#ERR="string" ??
answer: an error ...
so what does the IF do with an error? it's neither true, nor false.
You can simplify the situation to just this expression to see what's going on:
=IFERROR(A1,B1)="Bank BPH"
it returns an error.
Neither true nor false.
You're going to need another check condition for an error and how to handle it ..
perhaps:
=IF(AND(ISERROR(A1),ISERROR(B1)), "Manual post", IFERROR(A1,B1)="Bank BPH")
might do the trick ??
I think I figure out the correct syntax. I used to put the "AND(ISERROR(B18),ISERROR(A18)),"Manual Posting" to the end. However, I moved it at the beginning, it seems the problem can be solved.
=IF(AND(ISERROR(B18),ISERROR(A18)),"Manual Posting",IF(OR(IFERROR(B18,A18)="Bank BPH",IFERROR(B18,A18)="GE Budapest Bank"),"GE Capital",IF(IFERROR(B18,A18)="Avio Aero","GE Aviation",IFERROR(B18,A18))))

Resources