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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Problem When Comparing Columns

Status
Not open for further replies.

glthornton

Programmer
Oct 19, 2005
108
US
Hi,

I'm trying to create a cross-tab report (using Crystal Reports 10) to count the number of times a Primary Care Physician (PCP) has seen their own patients. I have an Appointments table that is setup like this:

Appt Date - Date/Time
Patient ID - Number
Patient Name - Text
GroupDocID - Number
EntityID - Number

Sample data would look like this:

Date PatID PT Name GroupDocID EntityID
11/01/05 123 John Doe 5249 5249
11/01/05 234 Jane Doe 5249 1383
11/02/05 345 Jamie Doe 5249 5249

I have tried using a Formula Field with the following code:

Code:
numberVar Seen := 0;
if {Table1.GroupDocID}={Table1.EntityID} 
then Seen=Seen+1

But the above code does not seem to work. What it does do is give me a count of all the lines found.

What I would like to have is a field that is equal to the total count where GroupDocID=EntitityID. And another field that contains the total count where GroupDocID<>EntityID. So in the above example, Seen = 2 and NotSeen=1.

Any ideas/suggestions would greatly be appreciated.

Thanks,
GlThornton
 
I have also tried the following code as well:

Code:
if {Table1.GroupDocID}={Table1.EntityID} the Count({Table1.PatID})

With the same result as the first code example.

GlThornton
 
Typo in the code above. The "the" should be a "then".
 
Your formula should be:

whileprintingrecords;
numberVar Seen;
if {Table1.GroupDocID}={Table1.EntityID} then
Seen := Seen + 1

Note that I removed the reset (to zero), since you want to accumulate this across records, and that I added a colon to the last line. You would use a separate formula to reset to zero if you are counting at a group level, and then you would use a separate display formula in the footer:

whileprintingrecords;
numbervar Seen;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top