Solved

Running Totals of Sub Reports

Posted on 2009-04-03
15
343 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
ID: 24061639
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
ID: 24061912
//@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
ID: 24061940
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 100

Expert Comment

by:mlmcc
ID: 24062350
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
ID: 24062697
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
ID: 24062770
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
ID: 24062950
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 24062985
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
ID: 24063857
Yes they appear correctly in the sub reports
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 24064455
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
ID: 24150488
still didn't work
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 24150747
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
ID: 24151671
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
ID: 24151938
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
ID: 24152175
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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