Solved

Running Totals of Sub Reports

Posted on 2009-04-03
15
340 Views
Last Modified: 2012-05-06
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?
0
Comment
Question by:chrisryhal
  • 7
  • 6
  • 2
15 Comments
 
LVL 17

Expert Comment

by:MIKE
Comment Utility
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;
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
//@MainSubSum1Display
whileprintingrecords;
global numbervar SUM1SUM;

                    appears not be 0.  

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

                    Works great on the SUB report
0
 
LVL 17

Expert Comment

by:MIKE
Comment Utility
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...
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
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"
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
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
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Do the correct values appear in the subreports?

The value in the mainreport page header will be 0

mlmcc
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
Yes they appear correctly in the sub reports
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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

0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
still didn't work
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
Actually I did get it working.  Problem is that the value needs to go ABOVE the Sub Reports????
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
0
 
LVL 2

Author Comment

by:chrisryhal
Comment Utility
mlmcc,

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

Appreciate the help!!
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
Comment Utility
Don't suppress it since it won't run then.
You have too do the suppression in the subreport so it doesn't display anything then you can suppress the blank section through the SECTION EXPERT

mlmcc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now