Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal Reports If true then return number else return NULL

In Crystal Reports, is it possible to have a function that returns a numeric value if the if statement evaluates to true and returns NULL otherwise?

I currently have

IF ({INDICATOR} = 'Y') Then
(
    {numeric value}
)
Else
(
    0
);

But since 0 is a possible value of {numeric value} it doesn't make sense. Rather, I would rather have that field come up blank if the indicator isn't 'Y', but when I replace the 0 with NULL it gives me a type mismatch error.

Is there a way for me to only show the value when the indicator is 'Y'?

like image 313
Nickknack Avatar asked Jul 20 '15 15:07

Nickknack


1 Answers

If you truly want a null value and not empty try the following

create a formula called NULL then save it and close without entering any data in the formula area. Then in your formula above try

If {INDICATOR} = 'Y' then {numeric value}
else tonumber({@NULL})
like image 196
CoSpringsGuy Avatar answered Oct 01 '22 17:10

CoSpringsGuy