有一个Crystal Reports公式将数字字符串转换为值,但保留非数字空格/ null [英] Have a Crystal Reports formula convert numeric strings to values, but leave non-numeric blank/null

查看:2283
本文介绍了有一个Crystal Reports公式将数字字符串转换为值,但保留非数字空格/ null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串字段,主要包含数字十进制值,但有时包含像< 0.10或HEMOLYSIS。

I have a string field that mostly contains numeric decimal values, but sometimes contains values like "<0.10" or "HEMOLYSIS".

if isNumeric({a_omgang.omg_resultat}) then
    toNumber({a_omgang.omg_resultat})


$ b <数值,这使得很难计算例如平均值或平均值,或计数值的数量。 (后者当然可以通过使用 isNumeric 评估公式的运行总计数来实现。)

returns 0 for all non-numeric values, which makes it hard to calculate e.g. average or mean, or to count the number of values. (The latter can of course be achieved by using a running total count with isNumeric evaluation formula.)

任何建议

编辑:我想要的值为空白(null),而不是只有非数字的可见性。

I want the value to be blank (null), not just turn of visibility if non-numeric.

推荐答案

过去,我创建了一个返回NULL的SQL表达式:

In the past, I've created a SQL Expression that returns a NULL:

-- {@DB_NULL}
-- Oracle syntax
(
SELECT NULL FROM DUAL
)

 

-- {@DB_NULL}
-- MS SQL syntax
(
SELECT NULL
)

然后我在公式中引用此字段:

Then I reference this field in the formula:

// {@FormulaField}
If IsNumberic({table.field} Then
  ToNumber({table.field})
Else
  ToNumber({@DB_NULL})

这篇关于有一个Crystal Reports公式将数字字符串转换为值,但保留非数字空格/ null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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