?
Solved

Crystal IF statement sometimes evaluates null. How is this possible?

Posted on 2014-09-24
2
Medium Priority
?
234 Views
Last Modified: 2014-09-29
I have the follwoing IF statement in a formula and I was expected it to never evaluate null which is why the "none" is added at the end. I will be adding more to this formula but I want it to work thus far before I proceed.

If (Not(IsNull({ARACCOUNT.ZZACPENDINS}))) and ({ARACCOUNT.ZZACPENDINS} < 0.00) Then
    "Insurance balance is negative - Notify Kathy"
Else If ({ARACCOUNT.ZZACSPORIGAMT} = 0) Or (IsNull({ARACCOUNT.ZZACSPORIGAMT})) Then
        "No charges"
    Else If ({ARACCOUNT.ZZACSPORIGAMT} - {ARACCOUNT.ZZACSPINSPMT} - {ARACCOUNT.ZZACSPINSADJ} - {ARACCOUNT.ZZACSPPMT} - {ARACCOUNT.ZZACSPADJ}) <> {ARACCOUNT.ARACNBTOTINI} Then
            "Mathematical issue"
        Else
            "None"
0
Comment
Question by:altosax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1600 total points
ID: 40342841
You need to test for NULL first.

When Crystal evaluates a formula and  it encounters a NULL in a test other than IsNull , evaluation terminates and the value returned cannot be predicted.

Change your formula to

If (Not(IsNull({ARACCOUNT.ZZACPENDINS}))) and ({ARACCOUNT.ZZACPENDINS} < 0.00) Then
     "Insurance balance is negative - Notify Kathy"
 Else If (IsNull({ARACCOUNT.ZZACSPORIGAMT}))  OR ({ARACCOUNT.ZZACSPORIGAMT} = 0) Then
         "No charges"
  Else If ({ARACCOUNT.ZZACSPORIGAMT} - {ARACCOUNT.ZZACSPINSPMT} - {ARACCOUNT.ZZACSPINSADJ} - {ARACCOUNT.ZZACSPPMT} - {ARACCOUNT.ZZACSPADJ}) <> {ARACCOUNT.ARACNBTOTINI} Then
             "Mathematical issue"
         Else
             "None" 

Open in new window

If any of the fields in the final IF can be NULL you have to handle them also.

mlmcc
0
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 400 total points
ID: 40343606
If you don't specifically need to see the nulls and just need to keep them from "breaking" your formula, then another option might be to change how CR handles nulls.

 More recent versions of CR have an option in the formula editor to control how CR handles nulls in a specific formula.

 Or, you can go to File > "Report Options" and check the "Convert database null values to default" option, but that will affect just about every formula in the report, so if there are any other formulas where you actually need to see null values, you may not want to use that setting.

 James
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question