Calculation with NULL values

I need this simple calculation:

(field B/C/D are looked up by relations from a MYSQL DB)

field_A = field_B + field_C + field_D

IF field_B/C/D is >= 0, the calculation is ok, but if a single field does not contain a value → NULL, the calculation of field_A is not possible.
Is there a way to define a NULL value as “0” ?
Or do i need to use if/then statements for each field before i can calculate the result ?
Is there a workaround ?

Thank you

Rainer Boehm

I did the same calculation and mine works fine.
The work around you propose is not nes because you can select the
‘allow null’ box in your dataprovider window. :wink:

Ron

The underlying SQL might have problems calculating with the null value.

What you could do as a workaround is first evaluate the fields you want to calculate with. If ino of them has a null value, exclude it from the calculation (if-then-else sortlike statement)

Paul

rainer / dsp:
field_A = field_B + field_C + field_D

one solution for field_A is:

if (field_B == null) field_B = 0;
if (field_C == null) field_C = 0;
if (field_D == null) field_D = 0;
return field_B + field_C + field_D;