Print Page | Close Window

IF...ELSE statement: the "ELSE" expression ignored

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21808
Printed Date: 07 May 2024 at 7:22pm


Topic: IF...ELSE statement: the "ELSE" expression ignored
Posted By: KartHol
Subject: IF...ELSE statement: the "ELSE" expression ignored
Date Posted: 15 Dec 2015 at 2:02am
Hello,

I've set up a formula field that should display string dependent on input condition (IF...THEN...ELSE). When the condition evaluates to TRUE the THEN... expression is correctly displayed, but when it evaluates to FALSE nothing is displayed. How is that possible?

I've attached two screenshots - the first one showing the definition of the "RC" field with formula and its use in the group header, the other one with the actual report with the "RC" field's missing content.

I use Crystal Reports 2008.

Pavel









Replies:
Posted By: kevlray
Date Posted: 15 Dec 2015 at 7:07am
My supervisor just had a similar issue with displaying a checkbox.  The only way we could get it to work was create a formula and reverse the true/false conditions.  Still do not understand why it would not work correctly.


Posted By: DBlank
Date Posted: 15 Dec 2015 at 9:08am
two things to consider
1. if you are dealing with NULL values, not empty strings then it will stop evaluating when it hits a NULL essentially returning nothing.
In the formula editor set the NULL option to 'use default values for null' to handle that condition.
Also you may want to trim the field in case it has a space in it.
2. Your formula is evaluating at the field level but is being displayed in the group header so it is only evaluating on the first row in the group and returning a result based on that row.


Posted By: KartHol
Date Posted: 15 Dec 2015 at 9:04pm
ad 1: Yes, it was a NULL value! My fault, I should have noticed that. I rewrote the formula using IsNull() function and now it works correctly.
ad 2: this is OK as I'm grouping by an order number and "RC" is a customer reference number for that order so it's the same for all order items.

Thank you very much, DBlank, for help! :)



Print Page | Close Window