问题描述
我有一个字符串字段,主要包含数字十进制值,但有时包含像< 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!