这个问题并不新鲜,但我整天都陷入困境。之前有人发布过:Crystal Reports: Error on Sum in Formula Field .i有报告计算公式通话收入的总收入:
if isnull({table.totalAmount}) and isnull({table.unpaidAmount})then 0 else
{table.totalAmount}-{table.unpaidAmount}
如果datasource不为空,但是如果数据源为空则抛出异常:Error in formula revenue: A number,current amount, date, time, or date-time is required here
关于如何解决这个问题的任何建议都会很棒!!
答案 0 :(得分:0)
当datasource为空时isnull
没有得到任何值,因此错误。试试这样:
if ({table.totalAmount}="" and {table.unpaidAmount}="")
then 0
else
{table.totalAmount}-{table.unpaidAmount}
答案 1 :(得分:0)
Crystal正在抛出异常,这很可能是因为{table.totalAmount}和/或{table.unpaidAmount}的数据类型是字符串而不是数字?
您可以将它们转换为数字:
ToNumber({table.totalAmount})
ToNumber({table.unpaidAmount})
或者,您可以检查数据是否为数字:
If IsNumeric({table.totalAmount}) and IsNumeric({table.unpaidAmount})
Then {table.totalAmount}-{table.unpaidAmount}
Else 0