Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show duplicate records only

Status
Not open for further replies.

greyknight17

Technical User
Sep 4, 2002
4
US
Hi,

I'm trying to get a list of patients who had the same identical exams performed. My report is grouped by date and patient name. I tried using the following suppression formula in the details section but it doesn't return the results I expected:

Code:
({Table.PatientName} <> next({Table.PatientName}) and {Table.ExamCode} <> next({Table.ExamCode})) or
({Table.PatientName} <> previous({Table.PatientName}) and {Table.ExamCode} <> previous({Table.ExamCode}))

The details section contains the patient name, exam code and other fields. I just want the report to return the details if a patient has more than 1 identical exam done.

Thanks.
 
It might work better to group on patientname, which you're probably already doing, and then group on exam code. Put a count in the group 2 footer and then filter/suppress to show only those groups where the count > 1 - in other words, those patients who have had the same exam more than once.
 
Thanks briangriffin. I used the summary count and have that in GF2 now but can't figure out how to suppress the group when count < 2.
 
Not sure what version you're using, but if you click the gold funnel icon for selection, one of the options is probably group selection. It works the same as for record selection, but instead you'll be filtering on the summary field you just created.

Your logic is 'under what circumstances do I want the group included in the report', so it will be something like count(fieldyourecounting, Table.ExamCode} > 1

Note: any additional totals in the report will probably be wrong, but in this case it doesn't seem like you'll be needing them anyway.
 
I'm using Crystal Reports XI.

I'm not sure what formula to use in the group selection formula. The field I'm counting is ExamCode. I can't use count({Table.ExamCode}) > 1 either because it returns the entire count of all the results in the report instead of by each group. I tried using the following also but only get a total count (I just want duplicate exams) of all exams by each patient:

Code:
Count({Table.ExamCode}, {Table.PatientName}) > 1

Yes, that's fine. I won't be using any total in this report. Just need those duplicate records returned.
 
Close - I think it should be this:

Count({Table.ExamCode}, {Table.ExamCode})

The second Table.ExamCode is the ExamCode group (you may have put the summary field in the patient group footer instead of the exam code group footer). Since group 1 is patient, group two is exams per patient.


GH1: Doe, John
GH2: Eye Exam
D: Eye Exam
D: Eye Exam
GF2: count of Eye Exam: 2
D: Foot Exam
GF2: count of Foot Exam: 1
GF1

Filtering on the count of exam would result in the eye exam group being visible and the foot exam group being suppressed.
 
That worked. Haven't used the group selection much and didn't know I can use count on the examcode like that.

Thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top