iif(Iserror())函数仍然返回#error [英] iif (Iserror ()) function still returning #error

查看:514
本文介绍了iif(Iserror())函数仍然返回#error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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

这与Excel文件相关联,人们将数字和文本放在同一列(本例中为F40 )。我需要知道我正在看的东西是数字还是文字。如果它是文本我想要一个零,如果它是一个数字我想要的数字。我知道当我在文本行上使用FormatNumber([C107_62xx]![F40])时,出现错误。我会假设,当我得到一个错误,然后我上面的iif公式将转换为零,世界会高兴。出于某种原因,即使使用我的iif语句,我仍然得到#error。我做错了什么?



我也尝试过使用IsNumeric函数,但我仍然得到#NUM!通过的错误。

解决方案

IsError 不符合您的想法。在帮助主题中,它返回一个布尔值,指示表达式是否为错误值。不是表达式触发错误,而是表达式 是一个错误值。



对不起,这个解释可能不够清楚,但我不知道该怎么做更好。所以我建议你在这里考虑这个 IsNumeric()表达式。

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

下面是输出中查询的相同表达式。

<前一个=lang-sql prettyprint-override> 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


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.

解决方案

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

这篇关于iif(Iserror())函数仍然返回#error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆