Crystal Reports formula field: IF ISNULL(decimal) THEN 0.00 … does not work correctly

大兔子大兔子 提交于 2019-12-12 02:23:43

问题


I have two values that I am pulling from my database:

{Command.AmountPaid} (of type Decimal(12,2))

{Command.AmountRefunded} (of type Decimal(12,2))

I am trying to create a formula field that will return {Command.AmountPaid} minus {Command.AmountRefunded}. Here is some pseudocode:

numbervar Paid := IF ISNULL({Command.AmountPaid}) THEN 0.00 ELSE {Command.AmountPaid};
numbervar Refund := IF ISNULL({Command.AmountRefunded}) THEN 0.00 ELSE {Command.AmountRefunded};

Paid - Refunded;

When null values are pulled, the ISNULL function is not recognizing them as null and is not returning 0.00. What am I doing wrong here?


回答1:


I know this doesn't solve the exact question you posed, but why not use ISNULL([AmountPaid], 0) AS AmountPaid within the command itself so that you have confidence that the values for those fields will always contain numbers?

(I know ISNULL is what you'd use if you were using SQL Server, I'm sure other DBs have similar functionality.)



来源:https://stackoverflow.com/questions/39252279/crystal-reports-formula-field-if-isnulldecimal-then-0-00-does-not-work-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!