Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formula not working Post Reply Post New Topic
Author Message
blandow
Newbie
Newbie


Joined: 22 Apr 2011
Online Status: Offline
Posts: 8
Quote blandow Replybullet Topic: Formula not working
     Posted: 25 Apr 2011 at 6:51am
I have 2 tables. They Both contain a field called "cust#"

If the cust# field on one table matches the other, I return the results in a new column with string "DI". If they dont match, the string should return "COPS". I have written the following formulas:
-------------------------------------------------------
StringVar RE;
If {dist_customer_billing_profiles.customer_no} = {customers.customer_no} Then RE := "DI"
Else RE := "COPS"
--------------------------------------------------------

Problem is that everything shows up as "DI", no matter if the criteria
is met or is not met. I've tried several joins, but still do not get what I need.

Thanks in advance for any help...
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 25 Apr 2011 at 8:06am

Looking at your formula, I assume that customers is your master table and dist_customer_billing_profiles is the child.  If this is correct, you need a left outer join FROM customer TO dist_customer_billing_profiles.  Then you should change your formula to this:

If IsNull({dist_customer_billing_profiles.customer_no}) then "COPS" else "DI"
 
Note that you do NOT need the variable.  The reason that your original formula does not work has to do with the way Null works.  Null means "no value".  When you do a comparison of the values of two fields and one or both is null, the result is null - NOT true or false.  For a good explanation of of how null works, go to the notes on the SAP Crystal Reports and Dashboard Design Facebook page (I can't get to Facebook from work or I would send you the link) - Last summer I wrote a note on "What is Null and Why is it Important" that is posted here.
 
-Dell


Edited by hilfy - 25 Apr 2011 at 8:06am
IP IP Logged
blandow
Newbie
Newbie


Joined: 22 Apr 2011
Online Status: Offline
Posts: 8
Quote blandow Replybullet Posted: 25 Apr 2011 at 9:36am
Thanks!! Looks like a winner!!!
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