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

sum of sum

Status
Not open for further replies.

Swetal2004

Technical User
Mar 5, 2004
30
US
Following is summary of a group:
Length Total Patient
of Stay Charge ID
Amount
10.00 101,629.19 10001
2.00 101,044.00 10002
9.00 124,394.28 10003
3.00 91,610.98 10004
10.00 122,430.49 10005
29.00 176,962.15 10006

I would like to average above summaries (length of stay and total charges)
If it is possible to do so in Crystal 8.5 Can you please assist me to do so and if not can show me the reason.
 
Crystal can't aggregate aggregates.

One solution is to divide the grand total by the count of groups (using a DistinctCount on whetever you are grouping on).

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thank you very much for your instant reply:

Length of stay, Total charge amount and patient Id are database field. Also there are duplicates records. So the table I had mailed before is in detail section and is grouped by another field not shown here.

Can I get around with this situation
 
A formula field can take two figures and give you an average. Or you could do two grand totals and then get the average of those.

Running totals also allow you to chose between several sorts of average, including 'weighted averages'.

You don't specify your exact methods. If you use running totals, they are working out at the same time as the Crystal report formats the line. This means you can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.
If you use summary totals, they are taken directly from the data and can be shown in the header. They can also be used to sort groups, or to suppress them.
If you want to get the summary totals for a database field, right click and choose Insert and Running Totals

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Apply the same logic but at level 1 instead of at Grand Total:

Sum({length_of_stay}, {Your_Level1_Group_field})/DistinctCount(Patient_ID,{Your_Level1_Group_field})

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thank you guys for your help.
I am trying to apply your ideas but it is still not giving
the results I want.

If you guys have other suggestions please feel free.
 
A bit vague. What results are you getting and in what ways do they deviate from the desired ones?


CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
If a report isn't working as you expect, add an extra section or two where you display whatever values you are working with. I've done it and found sometimes that data was not what I expected. Other times the running total (or whatever) was at fault. Anyway, you can crack the problem like that and then remove the untidy extras to get the final version for the business.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top