1
votes

I have below formula in my crystal report which doesn't work.

if({SINGLECASEMULTIPLEASSAY.sSampleName}="P")then
val({SINGLECASEMULTIPLEASSAY.sODValue})

The output of the formula field is always 0.00 although the table SINGLECASEMULTIPLEASSAY has correct values. I also verified that table SINGLECASEMULTIPLEASSAY has valid data.

2

2 Answers

3
votes

The VAL() function returns a numeric based on what text you are inputting.

If you are inputting text with no numbers in, this will return 0.00

If you inserted Val("2234 100th Street") you would get the result 2234100 - taken from IBM's webpage here.

Check the values in the field {SINGLECASEMULTIPLEASSAY.sODValue} and see if they contain any numbers; if they do make sure they are not prefixed by any spaces or letters.

If you are simply trying to display {SINGLECASEMULTIPLEASSAY.sODValue} then you do not need the VAL() function.

1
votes

You ALWAYS need to test for null values in Crystal Reports first:

If Isnull({SINGLECASEMULTIPLEASSAY.sSampleName}) Then
  0
Else If {SINGLECASEMULTIPLEASSAY.sSampleName}="P" Then
  ToNumber({SINGLECASEMULTIPLEASSAY.sODValue})