Search code examples
crystal-reportsformula

Calculation Error in Crystal Report Fomula


I have 2 decimal fields: GrossSalary and Deductions. In the report, I created a formula field named NetSalary, which is:

If Not IsNull({SalaryDetails.GrossAmount}) Then
 {SalaryDetails.GrossAmount} - {SalaryDetails.Deduction}

When data is available the report runs correctly, but if not I get the following error

A number, currency amount,date,time, or date-time is required here.
Details:errorKind
Error in File tempxxxxxxxxx.rpt:
Error in formula NetAmount:
'If Not IsNull({SalaryDetails.GrossAmount}) Then
'
A number,currency amount,date,time, or date-time is required here.
Details:errorKind

How can I fix this?


Solution

  • Crystal Reports will throw this error if it believes it is working with a value that is not a number. Crystal has many conversion functions like (CDBL, CSTR, etc) and also data check functions (IsNull, IsNumeric, etc) that you can use.

    In your particular case, converting the values to a DBL (CDBL({field}) solves your problem after Crystal checks for null values or blanks.