SASPYTHON
SASPYTHON

Reputation: 1621

Concatenate two coulmns when the field is NULL

For example I executed the code on SQL like this.

Fruits--- Taste
Orange -- good
Apple --  Bad
Apple -- 
Apple --

THEN

I go to Crystal Reports

I made a formula field with HTML TEXT format

{FRUITS}+"<i>"+"&nbsp;&nbsp;&nbsp;&nbsp;"+{TASTE}+"</i>"

Crystal Report is only showing

Orange   *good*
Apple    *Bad*

Where are these two apples go?
I assume since "TASTE" = NULL therefore, Crystal Reports removed the two apples.

How Can I show it like this on the report?

Orange   *good*
Apple    *Bad*
Apple
Apple

Upvotes: 1

Views: 1299

Answers (1)

MatSnow
MatSnow

Reputation: 7537

If the value of {TASTE} is NULL, then the formula "crashes" because NULL can't be concatenated with a string. Therefore the formula-field appears empty on the report.

You can fix this by checking for NULL. Change the formula like following:

If IsNull({TASTE}) Then
    {FRUITS}
Else
    {FRUITS}+"<i>"+"&nbsp;&nbsp;&nbsp;&nbsp;"+{TASTE}+"</i>"

Upvotes: 1

Related Questions