Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Finding records missing a certain field entry Post Reply Post New Topic
Author Message
jfdr31
Newbie
Newbie


Joined: 19 Feb 2015
Online Status: Offline
Posts: 9
Quote jfdr31 Replybullet Topic: Finding records missing a certain field entry
     Posted: 06 May 2015 at 5:56am
I have a table that lists information related to all patient reports written and I have a second table that shows when people attach files to the patient report.
 
I am trying to create a report that shows me any records in the first table that do not have a particular record entry in the second table
 
For example the first table lists records 1-1000, of that 1000 records I need to know which ones do not have a '.pco' entry in the attachment field of the second table
 
It is possible that a record may have another type of attachment but they all are supposed to have the '.pco' attachment and I just need a list of those that do not.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 May 2015 at 7:36am
can you create a command or stored procedure?
IP IP Logged
jfdr31
Newbie
Newbie


Joined: 19 Feb 2015
Online Status: Offline
Posts: 9
Quote jfdr31 Replybullet Posted: 06 May 2015 at 11:11am
Is there a simpler way to do it using the correct joins and filters or are those two my only options. If you have an example that would be greatly appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 May 2015 at 4:07am
the store proc or command can use "where not exists"
like this
 
select * from Patients P
where not exists
 (select 1 from PatientFiles PF
 where attachmentfield = '.pco' and  PF.ClientId = P.ClientId)
 
or you can do this in crystal using a group select process
pull all records into the report (outer joining the two tables)
group on the patients.id field
create a formual field (called 'flag' or whatever you want) to find rows with the '.pco' value
//flag
if table.field = '.pco' then 1 else 0
make sure this formula is set to use "default values for Nulls"
insert a summary as teh SUM of the flag formula field at the patient group footer
SUM(@flag,patient.id)
Now all of your patients missing the pco will have a sum of 0
use that in the group select criteria
SUM(@flag,patient.id)=0
 
IP IP Logged
jfdr31
Newbie
Newbie


Joined: 19 Feb 2015
Online Status: Offline
Posts: 9
Quote jfdr31 Replybullet Posted: 07 May 2015 at 10:18am
Thank you. The bottom part is what I really needed to take me to the next step in Crystal. It worked perfectly.
IP IP Logged
jfdr31
Newbie
Newbie


Joined: 19 Feb 2015
Online Status: Offline
Posts: 9
Quote jfdr31 Replybullet Posted: 07 May 2015 at 10:47am
Ok, so now that I have this great list of patient reports that do not have that certain attachment, how do I get it to group and sort by the report writer?
 
It seems that either the original group on record id or the group select sum is preventing me from grouping this result set by the person who wrote the report (i.e. - now that I have the list of reports by missing attachments I need to group it by the report writer to identify the frequent offenders)
 
I tried adding report writer to the grouping layer but it did not truly group them together.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 May 2015 at 11:06am
that is the rub of using crystal to get your list.
It has to be grouped and use a group sum to get the 'group results' that you can 'present like a list' but it is still a group. This cannot be regrouped.
 
If you only have one 'report writer' per patient you can insert a group summary as a min or max on that name field then you can sort the groups on that min or max group value. You can also get a summary in the report footer using Running Total with a conditional count
Otherwise consider getting your patient list using the command object option. Then you can use crystal in other ways with that data set.


Edited by DBlank - 07 May 2015 at 11:15am
IP IP Logged
jfdr31
Newbie
Newbie


Joined: 19 Feb 2015
Online Status: Offline
Posts: 9
Quote jfdr31 Replybullet Posted: 07 May 2015 at 11:12am
Thanks for your help. I will try that.
 
Also, when you get a chance, no hurry, I posted a furthering education question in the "Ask the Author" section of the forum.
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