Skip to Content
May 05, 2017 at 04:23 PM

Crystal Reports - Filter a group before counting group


I have a report that needs 2 criteria:

1. Patients who do not have a custom note in the database with subject of "Ladder".

2. Patients with 6 or less visits to our clinic in the past.

The problem is, a patient could have more than 6 "custom notes", so this creates duplicate entries - correctly, as it is a 1 to many relationship.

However, this creates "more than 6 records", so patients who should be included in the report are omitted because I have a group selection formula limiting the records to be "6 or less for each patient".

If I do only a "record" select to delete the notes with "Ladder" in the subject, it only deletes those records, but keeps other records for that patient, since there are "other" notes not being deleted. The "Ladder" criteria must be looked at as a group.

Here is my current group formula, which works correctly until I add a formula to filter the "Ladder" notes out:

(Count({vwGenSvcInfo.Primary_Diagnosis_Code},{Appointments.Appointment_DateTime}) <= 6

Any help is appreciated!