Displaying a gender pie chart in Crystal Reports XI

I am returing data from an MS SQL Server database where each row represents a patients visits to a hospital and clinic.

A patient can make many visits so they can be represented by more than one row in the dataset.

I need to count the number of patients. Easy! A distinct count of the patient id field.

I also need to show the percentages of men and women.  And then i need to show this in a pie chart.

This is cause me problems.  

It must be a pretty standard problem.  I have tried using running totals, but then i cant show them in the pie chart.

Anyone any ideas how to solve this?
Who is Participating?
mlmccConnect With a Mentor Commented:
Try this idea

Add a formula

If {GenderField} = "M" then
    {PatientIdField} & " MALE"
    {PatientIdField} & " FEMALE"

You should be able to use a distinct count on that

If the Patient Id is numeric

If {GenderField} = "M" then
   CStr({PatientIdField},0,"") & " MALE"
   CStr({PatientIdField},0,"") & " FEMALE"


soozhAuthor Commented:
hej... thats quite clever... let me check it out.
Another note: if you need a math formula, the equation is below:

Distinct Count of Males / Distinct Count of Patients = % of Males
Distinct Count of Females / Distinct Count of Patients = % of Females

Once you create these two as formula fields, you can add it to a pie chart as an unlinked subreport and display the pie chart on the order header and anything else you want below it.
No need for that.  The chart allows you to display the results as the number or a percent and does it correctly

All Courses

From novice to tech pro — start learning today.