Link to home
Start Free TrialLog in
Avatar of chrisryhal
chrisryhal

asked on

Running Totals of Sub Reports

I have a main report with 2 Sub Reports.   Both Sub reports have a Running Total "SUM" of a column called "Unit Price"  

Is there ANY way on the MAIN report, to have a Total "SUM" of both Running Totals from teh Sub reports?
Avatar of Marcus Aurelius
Marcus Aurelius
Flag of United States of America image

Yes..you need to create a formula that contains a VARIABLE to catch or HOLD the summaries from the Subs.

I think you can use the Running Subtotal if you choose it from the DataFields.

Formula IN the SUB will look like this:

//@SubSum1
whileprintingrecords;
global numbervar SUB1SUM:= [Your Running Sub-total field here]  <====choose from field choices

Keep in mind GROUPING requirements...choose the GROUP instance of the subtotal.

Formula for the Main Report will look something like this:

//@MainSubSum1Display
whileprintingrecords;
global numbervar SUM1SUM;
Avatar of chrisryhal
chrisryhal

ASKER

//@MainSubSum1Display
whileprintingrecords;
global numbervar SUM1SUM;

                    appears not be 0.  

//@SubSum1
whileprintingrecords;
global numbervar SUB1SUM:= {#RTotal0}

                    Works great on the SUB report
Ok..so tell me more about the subs...so how are they linked to the main....are the subs based on GROUPING of the main?

IF you have screenshots of main showing where subs come into play..it would be great...
You need to use SHARED rather than global.

Global variables only work on a report.
Shared allows the data to pass between the main and subreports.

In the main report header add a formula

whileprintingrecords;
Shared numbervar SUM1SUM;
Shared numbervar SUM2SUM;

Where you want to use it in the main report.  It must be after the subreport

whileprintingrecords;
Shared numbervar SUM1SUM;
Shared numbervar SUM2SUM;
SUM1SUM + SUM2SUM
In the subreport

//@SubSum1
whileprintingrecords;
Shared numbervar SUB1SUM:= {#RTotal0}

//@SubSum2
whileprintingrecords;
Shared numbervar SUB2SUM:= {#RTotal0}

mlmcc
mlmcc,

Added the @SubSum's on the sub reports like so:

     //@SubSum1
     whileprintingrecords;
     Shared numbervar SUB1SUM:= {#RTotal0}

The value DOES show on the sub reports.

Added the:
     whileprintingrecords;
     Shared numbervar SUM1SUM;
     Shared numbervar SUM2SUM;

In the main report header.  Then RIGHT AFTER both Sub Reports, I added as you instructed:

     whileprintingrecords;
     Shared numbervar SUM1SUM;
     Shared numbervar SUM2SUM;
     SUM1SUM + SUM2SUM

Value displaying on the main report is "0.00"
Here, I zipped it up if that helps.  Change the file extension to .RPT cause EE won't accept it.

I placed RED textbox on where I did what was instructed to do.
CCI.txt
To use the values the formula in the main report must be after the subreport

The formula for the report header is simply to declare the variables for the main report
     whileprintingrecords;
     Shared numbervar SUM1SUM;
     Shared numbervar SUM2SUM;

In a later section after the subreports add the other formula     whileprintingrecords;
     Shared numbervar SUM1SUM;
     Shared numbervar SUM2SUM;
     SUM1SUM + SUM2SUM

mlmcc
Do the correct values appear in the subreports?

The value in the mainreport page header will be 0

mlmcc
Yes they appear correctly in the sub reports
In the main report you have

whileprintingrecords;
Shared numbervar SUM1SUM;
Shared numbervar SUM2SUM;

In the subreports you use

whileprintingrecords;
Shared numbervar SUB1SUM;

whileprintingrecords;
Shared numbervar SUB2SUM;

They have to have the same names throughout.  Change the main report to
Report header
whileprintingrecords;
Shared numbervar SUB1SUM;
Shared numbervar SUB2SUM;

ReportFooter
whileprintingrecords;
Shared numbervar SUB1SUM;
Shared numbervar SUB2SUM;
SUB1SUM + SUB2SUM

mlmcc

still didn't work
Actually I did get it working.  Problem is that the value needs to go ABOVE the Sub Reports????
Can't be done since that part is printed before the subreports are run.

Actually you could by having the subreport in twice.
One that just gets the values you need
The other that displays later

mlmcc
mlmcc,

Thats true, I could just have it in there, but surpressed if you agre?  Good idea, will try that.  

Appreciate the help!!
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial