Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If-Then-Else Statement for NULL Values Post Reply Post New Topic
Author Message
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Topic: If-Then-Else Statement for NULL Values
     Posted: 26 Oct 2009 at 11:20am

I am using a report with 5 tables of data and am having trouble with Null Values. The tables are named CLASS, FAILUREMARK, LABOR, LABTRANS, & WORKORDER. I have no trouble bringing in the data until I included this field {FAILUREREMARK.DESCRIPTION}.  If the field is Null, then the record will not show at all. I have the ‘Convert database NULL values to default’ in the options and report options. I have also reviewed several websites showing different ways to show Null records with the If-then-else statement.

 

My question is what would be the formula for this, and where do I place it. I am filtering records from the Select Expert section: {LABTRANS.REFWO} like ["4170936", "5622714"]. Do I create a formula with the If-then-else statement and place it somewhere on the report, or can this be placed in the same Select Expert formula listed above.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Oct 2009 at 12:19pm

Likely what the underlying problem here is you are using an inner join to your FAILUREREMARK table and the NULLS are really rows from the other table that have no match in the FAILUREREMARK table.

Is this likely?
If so, try changing this to a left outer join.


Edited by DBlank - 26 Oct 2009 at 1:17pm
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 26 Oct 2009 at 1:15pm
I did try this but was unsuccessful. Thanks for the suggestion though. (Crystal Report XI)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Oct 2009 at 1:34pm

There are a number of ways to display NULLS but your description leads me believe that this is still a join issue.

If your links are set as "Not Enforced" and you are not using any fields from your failuremark table it is likely not being included in the join process. If when you add any field form this table (in a formula, select statment, or just to the report canvas as you described) rows disappear from the report it is because it is now enforcing the join and dropping records that are not matched in the table linking processes.
Is this a valid description of what is happening?
If not, can you describe what is happening?
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 26 Oct 2009 at 2:23pm

All of the links are set to INNER JOIN, except for the FAILUREREMARK table, which you mentioned to make LEFT OUTER JOIN. All of the table links are NOT ENFORCED.

 

 

I am pulling this data out of an ODBC database, to which I can see the tables and records. In the Crystal Report, I am filtering the report to show only two records from the {FAILUREREMARK.DESCRIPTION} field, which in the ODBC database, I can see one is populated, and the other one IsNull.

 

As soon as I pull the {FAILUREREMARK.DESCRIPTION} out of the Crystal Report, both records appear, but when it’s added, the one with the populated field is the only one that shows up.

 

Thanks for your help. Unfortunately, I will have to work more on this tomorrow. Thanks again.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 Oct 2009 at 2:34pm
Your description of what happens really sounds like it is the join.
Trya nd swap it to a Right Outer join. Depends on which way you have your tables linked to know to use a a Right or Left join.


Edited by DBlank - 26 Oct 2009 at 2:34pm
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 27 Oct 2009 at 6:14am
Switching the join from a Left Outer join to a Right Outer join worked! I obviously need to read up on the differences of the join links-when to use, and when not to use. I have been battling this problem for quite some time now, so I'm glad it's finally resolved.
 
Thanks for your time and help DBlank.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum