Search code examples
crystal-reports

crystal report how to extract the correct value?


My report have an error using below script.

If the field have value will display the value inside, if don't have need to set it as 0, but report show empty value.

If {Invoice.TaxExempted} <> "" then 
     tonumber({Invoice.TaxExempted})
else 
     tonumber(0)

Result

if have value 400 : it do display 400.00

but if empty value : it just show empty only, but i wish it display 0.00


Solution

  • Most likely, the field is not blank (""). Instead, it's NULL. So change the formula to:

    if isnull({Invoice.TaxExempted}) Then
      0
    else
      tonumber({Invoice.TaxExempted})