Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How to filter one table record from second table Post Reply Post New Topic
Author Message
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Topic: How to filter one table record from second table
     Posted: 29 Dec 2009 at 1:21pm
I have a report that is giving me some staffing information for events. I have one table that has some basic event info like customer, date, event ID etc. I have a second joined table that has details for the event like chairs, tables, etc. I can have several entries from the second table for each record in the first table. I need to create a formula or select that will filter out records from the first table based on the details in the second table. Here is what I have

Table1.recordID     Table1. ClientName  Table1.EventDate   Table2.Supplies
5                               Bob's Trucking            5/15/2010                chairs
5                               Bob's Trucking            5/15/2010                tables
5                               Bob's Trucking            5/15/2010                Tent
6                                Joe's Plumbing           6/5/2010                  chairs
6                                Joe's Plumbing           6/5/2010                  tables

What I am trying to do is if the Table2.Supplies field = Tent then
Skip the Table1.RecordID completely. Currently if I filter out "Tent"
I get
Table1.recordID     Table1. ClientName  Table1.EventDate   Table2.Supplies
5                               Bob's Trucking            5/15/2010                chairs
5                               Bob's Trucking            5/15/2010                tables
6                                Joe's Plumbing           6/5/2010                  chairs
6                                Joe's Plumbing           6/5/2010                  tables

and what I need to get is just

6                                Joe's Plumbing           6/5/2010                  chairs
6                                Joe's Plumbing           6/5/2010                  tables

Basically I need any record from Table1 as long as none of the matching records in Table.Supplies = Tent.

Thanks,
Flanman
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Dec 2009 at 1:30pm
Group on table1.recordid
create a flag formula to determine which items to remove as
if {table2.supplies}="Tent" then 1 else 0
insert a Summary of this flag as a SUM at the group level
SUM({@flag}, {table1.recordid})
Use the select expert GROUP SELECTION to filter your data
 SUM({@flag}, {table1.recordid})=0
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Dec 2009 at 1:31pm
or you can do this in a SQL view or command writing your join to handle this issue
IP IP Logged
flanman
Senior Member
Senior Member
Avatar

Joined: 04 Nov 2009
Online Status: Offline
Posts: 123
Quote flanman Replybullet Posted: 29 Dec 2009 at 1:59pm
Once again great help from this forum. I did the first option and it worked like a charm.

Flanman
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