Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: If Then Else with multiple returns Post Reply Post New Topic
Author Message
miamitourism
Newbie
Newbie
Avatar

Joined: 14 Jan 2011
Online Status: Offline
Posts: 24
Quote miamitourism Replybullet Topic: If Then Else with multiple returns
     Posted: 17 Mar 2011 at 8:02am

Hello!

I need some help with something tricky...
 
I am trying to run a report of all customers, grouped by region and in a particular status from my database.  That part works fine, and it's not a problem.  In addition to this, though, each record needs to show whether this customer is either "Environmentally Friendly", "Certified Green" or both (and the record needs to show also if neither apply), based on two codes (ENVIRONF and CERTGREEN).  The list needs to remain grouped by region, and then alpha ascending by name. 
 
Here's what I have so far:
- I have inserted in the details section, the customer name field, and also the address 1 field.
-  I have created two formulas for the "ENVIRONF" and "CERTGREEN", but something about this formula is not giving me what I want and I will explain in just a moment:
   If {ip_Minor_Codes.Minor_Code} = "ENVIRONF" Then "Y" Else ""
   If {ip_Minor_Codes.Minor_Code} = "CERTGREEN" Then "Y" Else ""
- I have inserted these two formulas in the details section, each under a column header. The idea is that I want Crystal to put a "Y" in the column, if the record has one or both codes.  If no code is present, I still need the record to show, though, just with no "Y" in either column representing the "Certified" or "Environmentally Friendly".
 
The issue I have is that in the field in the database that stores the two codes I reference above, there are also many other codes to indicate other things such as what business type, status, whatever... each record contains many different codes, and they are all different.  What happened in my report was that all of a sudden when I added the formulas, each customer was listed over and over, the exact number of times for the number of codes that exist in that field.
 
Does anyone have any ideas on how to achieve this?  For visual reference, here is an example of what I would need:
 
Customer     Address1     Cert     EnvrionF
ABC Co.        123 Main      Y
123 Co.        123 Main              
DEF Co.        123 Main      Y          Y
456 Co.        123 Main                  Y
 
Thank you so much in advance for any ideas!
 
Sarah
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Mar 2011 at 8:34am
you will have to group on customer, change your formula to use variables and check all the records for the 'green' records and place the results on the group footers and suppress the details section.
or change your formulas to
formula_A:   If {ip_Minor_Codes.Minor_Code} = "ENVIRONF" Then 1
formula_B:   If {ip_Minor_Codes.Minor_Code} = "CERTGREEN" Then 1
add two more formulas to use for your Y display in the group headers
if SUM(formula_A,customer)>0 then 'Y'
if SUM(formula_B,customer)>0 then 'Y'


Edited by DBlank - 17 Mar 2011 at 8:34am
IP IP Logged
miamitourism
Newbie
Newbie
Avatar

Joined: 14 Jan 2011
Online Status: Offline
Posts: 24
Quote miamitourism Replybullet Posted: 17 Mar 2011 at 8:41am
Thanks for that... will give it a try in a few minutes... Will this still include records that do not have either of the two codes?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Mar 2011 at 8:43am
yes, they will be grouped but have blanks in the Cert and EnvrionF 'rows'.
IP IP Logged
miamitourism
Newbie
Newbie
Avatar

Joined: 14 Jan 2011
Online Status: Offline
Posts: 24
Quote miamitourism Replybullet Posted: 17 Mar 2011 at 8:50am
Thanks- I'm very excited to try this once I get out of this Crystal Reports class I'm in at the moment.  It's an advanced class, and please note, my instructor did not have the answer to this one, and he's pretty good! Clap
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