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

Sum of subreport data 2

Status
Not open for further replies.

ask4help

Technical User
Mar 1, 2007
14
0
0
US
I have a report that queries the part number and then links to a subreport to find all customer orders with that part and average the selling price. The average selling price is displayed on the main report for each part number. How can I sum all the averages from the subreport on the main report?
 
If you are not already doing this, create a formula in the subreport and place it in the subreport report footer:

whileprintingrecords;
shared currencyvar aveprice := average({table.sellingprice});

Then in the main report in a section below the one in which the subreport is located (i.e. GH_b if the sub is in GH_a), add a formula like this:

whileprintingrecords;
shared currencyvar aveprice;
shared currencyvar sumave;
sumave := sumave + aveprice;//accumulates the average
aveprice;//displays the average at the group level

Then in the report footer, add this formula:
whileprintingrecords;
shared currencyvar sumave;

If the sub can be null, you should have a reset formula for the shared variable:

whileprintingrecords;
shared currencyvar aveprice := 0;

Place this in the report header and in the group footer section.

If your price is actually a number, not a currency, change all references to currencyvar in the formulas above to numbervar.

-LB
 
Are you sure you need a subreport for this? It doesn't sound like you do. If you can avoid subreports it will probably increase your report performance dramatically.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top