Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iif (Iserror ()) function still returning #error

I have the following function that creates a column in my query:

MTD: IIf(IsError(FormatNumber([62xx]![F40])),0,FormatNumber([62xx]![F40]))

This is linked to an Excel file and where people put numbers and text in the same column (F40 in this example). I need to know if the thing I am looking at is a number or text. If it's text I want a zero, if it is a number I want the number. I know that when I use FormatNumber([C107_62xx]![F40]) on a text line I get an error. I would assume when I get an error, then my iif formula above would convert that to a zero and the world would rejoice. For some reason I am still getting a #error even with my iif statement. What am I doing wrong?

I have also tried using the IsNumeric function but I still get #NUM! errors that come through.

like image 986
Nigel Avatar asked Mar 26 '14 18:03

Nigel


People also ask

How do you use Iserror formula?

ISERROR ( (C4-B4) / C4 ) will check if the mathematical operation (C4-B4) / C4 gives an error. In this case, it will return “FALSE.” If (ISERROR ( (C4-B4) / C4 ) ) returns “TRUE,” the IF function will not return anything. If (ISERROR ( (C4-B4) / C4 ) ) returns “FALSE,” the IF function will return (C4-B4) / C4.

What is if Iserror in Excel?

The IsError function is used to determine if a numeric expression represents an error. IsError returns True if the expression argument indicates an error; otherwise, it returns False.

What is the difference between Iserror and Iferror?

IFERROR allows you to specify only value_if_error. If there is no error, it always returns the result of the tested value/formula. IF ISERROR provides more flexibility and lets you handle both situations - what should happen if an error and what if no error.


1 Answers

IsError does not do what you think it does. From the help topic, it "Returns a Boolean value indicating whether an expression is an error value." Not whether the expression triggers an error, but whether the expression is an error value.

Sorry, that explanation was probably not clear enough, but I don't know how to do better. So I'll just suggest you consider this IsNumeric() expression for what you want here.

IIf(IsNumeric([62xx]![F40]), FormatNumber([62xx]![F40]), 0)

Here is that same expression in a query with the output below.

SELECT
    [62xx].F40,
    IIf(IsNumeric([62xx]![F40]), FormatNumber([62xx]![F40]), 0) AS MTD
FROM [62xx];
F40    MTD
-----  ----
foo    0
1      1.00
2.345  2.35
bar    0
like image 115
HansUp Avatar answered Sep 19 '22 17:09

HansUp