[英]Problems converting a crystal reports running total string to a number
I have a problem with converting a running totals string to a number. 将运行中的总计字符串转换为数字时遇到问题。
The running total is set to retrieve the maximum value of a field that contains results. 设置运行总计以检索包含结果的字段的最大值。 It is reset with change of a group and evaluated by a formula so that only results from a specific test is used. 更改组后将其重置,并通过公式进行评估,以便仅使用特定测试的结果。
The result database field is a string since there are test with text results as well as tests with numeric results in the database. 结果数据库字段是一个字符串,因为数据库中存在文本结果测试和数字结果测试。 The test I'm filtering out only have numeric results (saved as string). 我过滤掉的测试只有数字结果(保存为字符串)。
The running total works fine and gives the correct result, but I want to change it from a string to a number to be able to set the number of decimals and use rounding in the report, and this is where my problem begins. 运行总计工作正常并给出正确的结果,但是我想将其从字符串更改为数字,以便能够设置小数位数并在报告中使用四舍五入,这就是我的问题所在。
I've tried using a formula field with the following formula: 我尝试将公式字段与以下公式一起使用:
if isNumeric({#P-LDL}) then toNumber({#P-LDL})
but that returns 0.00 for all non-null values even though the strings are nice things like "2.36" or "3.74" (without the quotes). 但是,即使字符串是“ 2.36”或“ 3.74”之类的好东西(不带引号),对于所有非空值也返回0.00。
Solved it: 解决了:
if NumericText(Replace({#P-LDL}, ".", ",")) then
ToNumber(Replace({#P-LDL}, ".", ","))
Stupid locales... 愚蠢的语言环境...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.