Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Linking problems Post Reply Post New Topic
Author Message
uhuruguy
Newbie
Newbie


Joined: 01 Jul 2009
Location: Norway
Online Status: Offline
Posts: 2
Quote uhuruguy Replybullet Topic: Linking problems
     Posted: 01 Jul 2009 at 4:01am
Hello,

I have a problem i still haven't figured out how to solve in Crystal Reports.

Example: I have two tables

A)person - a table that stores information about a person, say adress, date of birth etc.

B) reservations - a table where you can store information about what 'channels' a person does not want to be contacted through, say phone, SMS, e-mail etc. A person can be represented several times in this table, say the person does not want to be contacted through sms and phone, then there will be two records for this person in the table.

Both tables have a person idnumber as the linking column.

I have problems making a report that views all the persons that does NOT have a record in the reservations table with a certain code, for intstance phone, if I want to show every person we can call. I only get those persons that are represented in the reservations table, but I want to see every person that does not have reservation against phone.


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Jul 2009 at 6:20am

Hmm...interesting question... No particular join is going to help.  In SQL, I would do something like:

select *
from person p
 left join (select idnumber from reservations where channel = 'sms')ss
  on ss.idnumber = p.idnumber
where ss.idnumber is null
 
This obviously only works for 1 channel at a time, but it could be more robust, you would have to play around with it.
 
Unfortunately, I don't join to the tables in Crystal, so I am not sure how to accomplish something like this.  All of my reports are driven off of stored procedures.
 
Sorry couldn't be of more help.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Jul 2009 at 7:29am

One way you can do this in crystal is:

1. If there are records in the person table with NO records in the reservations table you will need to left join the tables to get all records from Persons.

2. Group on PErson - Preferably a Key like personID so 2 different people are not stuck int he same group.

3. Create a formula to find which persons have the contact mode you want to exclude. (YOu can also do this via a parameter so you can have 1 report for any type) ...
if {reservation.channel}="Email" then 1 else 0
Email is just the sample and can be replaced by any type or a parameter option.
4. Create a Summary Function of the above formula field as a SUM at group level1 (person).
5. Use the Select Expert with the Group Selection option toggled on and exculde any item where step #4's summary is >0 (make sure you also do not lose any NULL values here).
IP IP Logged
uhuruguy
Newbie
Newbie


Joined: 01 Jul 2009
Location: Norway
Online Status: Offline
Posts: 2
Quote uhuruguy Replybullet Posted: 02 Jul 2009 at 4:32am
I think this one will work perfectly well. Thank's a lot (and a bit annoyed that I didn't think of this myself...Smile)
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