问题
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