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

summing a formula 1

Status
Not open for further replies.

sorchard2000

Technical User
Aug 3, 2004
57
US
Crystal 8.5
SQL Server

I am trying to create a report that looks like:
date range (from end user putting in parameters.)
Group 1: Doctor's name
Group 2a: Name of patient that he did surgery on
Group 2b: Subreport listing items and cost (linked to main report)
Group 2c: Subreport listing imlants and cost (linked to main report)
Detail band: Surgeries performed on that patient (since a patient may have more than one surgery)
Group footer 2a: @totalcost formula showing sum of items and implants from subreports.
Report footer: @GrandtotalMD showing grand total of all costs and implants for that doctor.

current formulas:
//@GrandTotalMD
WhilePrintingRecords;
currencyVar TotalCost := TotalCost + {@TotalCost}

//@GrandTotalMDFooter
whileprintingrecords;
currencyVar TotalCost;

Problem is: @GrandTotalMD displays Grand Total of ALL surgeons in that date range instead of that individual surgeon in the Group 1. I need it to show that Surgeon Smith total (for 4 surgeries) is $xxx.xx.

Thanks so much for any help given.
sorchard2000
 
Do you mean to display the result in the group#1 (doctor) footer? Then all you need to do is add a reset formula, placed in GH#1:

whileprintingrecords;
currencyvar TotalCost := 0;

-LB

 
lbass:
Sorry, but that didn't work. I'm still getting a completely wrong $ total with the @GrandTotalMD and @GrandTotalMDFooter. And when I add in your formula, it was still wrong.

@totalcost reflects all items used for that patient.
My intent with @GrandTotalMD is to have the formula add up all the @totalcost(s) for that doctor, so I could have a grand total of his total cost for that procedure (for all his patients).

I'm very grateful for any help we get on this since this has had us stumped for quite a while. Thanks!
 
Sorchard,

There's a possibility that you may have misunderstood lbass' post, as her additional formula is the missing link to your two.

The only other thing to add is if your costs are coming from your subreports, and you're using the same variables in the subreport, then I would suggest that your variables should be shared variables, as opposed to global variables.

In GH1, place:
whileprintingrecords;
shared currencyvar TotalCost := 0;

In Details or wherever is relevant for the subreports, place:
current formulas:
//@GrandTotalMD
WhilePrintingRecords;
shared currencyVar TotalCost := TotalCost + {@TotalCost}

In GF1, place:
//@GrandTotalMDFooter
whileprintingrecords;
shared currencyVar TotalCost;

Naith
 
Naith and lbass:
Your suggestions worked great after Naith explained them a little better to my simple mind!! Thanks for all your help!

Now my next question is, how do we get an average (for that doctor) of the @GrandTotalMDFooter?

You people are so smart!

sorchard2000
 
{@GrandTotalMDFooter} / Count({YourRecordIDHere})
 
Thanks SO much for your help! It worked perfectly! You've made us very happy!

sorchard2000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top