codematrix
codematrix

Reputation: 1621

Formula in Crystal report doesn't work

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.

Upvotes: 1

Views: 1773

Answers (2)

craig
craig

Reputation: 26272

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})

Upvotes: 1

vice
vice

Reputation: 605

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.

Upvotes: 3

Related Questions