Avatar of rayrover00
rayrover00Flag for United States of America asked on

Crystal Reports XI - syntax question If, then else

I have this as code in a formula:

if {brptPRRegister;1.EarnCode} in [125, 126, 401] then ""
else {brptPRRegister;1.EarnCode}

what I want is for the result of this field NOT to include 125, 126 or 401, but everything else. The
field {brptPRRegister;1.EarnCode} is a number type.

The error I get is the part after the "else" gets highlighted and says a string is required here. Am I even writing this properly to get what I want?

Crystal Reports

Avatar of undefined
Last Comment
rayrover00

8/22/2022 - Mon
dougvarga

Close.

Because EarnCode is a number, you need to decide if you want this to return a number or a string.  My guess is you don't care.

Try it this way:

if {brptPRRegister;1.EarnCode} in [125, 126, 401] then ""
else Cstr({brptPRRegister;1.EarnCode},0)
ASKER
rayrover00

on the last part where you put in the zero, how can you fix that if what you are evaluating is a null? so that a null just shows...or blank, really?
dougvarga

if IsNull({brptPRRegister;1.EarnCode}) or {brptPRRegister;1.EarnCode}  in [125, 126, 401] then ""
else Cstr({brptPRRegister;1.EarnCode},0)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
rayrover00

I still have a zero showing up. hhhmmmm
ASKER CERTIFIED SOLUTION
dougvarga

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
rayrover00

awesome!!! Thanks and thanks for so fast!!!