Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to get a summary of a calculation from a subreport to the main report in Crystal Reports 2008

Posted on 2013-01-11
7
Medium Priority
?
969 Views
Last Modified: 2013-01-11
Hi,
      I have a subreport placed in the group header of a main report in Crystal Reports 2008. The subreport has an average calculated for the records in it using a formula (Sum/Count). So, the main report shows an average for each group as the subreport is placed in the group header. Could anyone tell me how to get the total average on the main report for the field which is in the subreport ?


Thanks in advance.
0
Comment
Question by:pradeepdevineni
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 23

Expert Comment

by:Ido Millet
ID: 38767036
Set the value of a Shared variable in a subreport formula.  A main report formula in a section BELOW the subreport section (in your case, a good choice would be in the Group Footer section) can then declare the same shared variable name and gain access to the value in it.
0
 

Author Comment

by:pradeepdevineni
ID: 38767260
Thanks for your quick reply. I used the shared variables and got the average to display on the group footer of the main report. The result in the main report now shows an average for each group. This is the first part of my question which is solved.

Now, How can I get the "Total Average" (which means the average of all the records in all the groups) to display on the Report Footer of the main report ?

I tried to put the main report formula in the Report Footer of the main report. It didn't work. Do I have to change the location of the subreport ? I still need both the group averages and the Total average.
0
 
LVL 23

Expert Comment

by:Ido Millet
ID: 38767284
Since you now have access to the data in the subreports, just decide what you want to do with that data.  You can use other variables to accumulate the Grand Total Value and Grand Count, so that in the Report Footer you can divide one by the other to get the desired Grand Average.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:pradeepdevineni
ID: 38767571
I used shared variables to get the group sum and group counts from the subreport to the main report and divided them to get the Group average.

I tried to create running totals for the group sum and group counts in order to create the Grand sum and Grand counts. It doesn't let me do the running totals. I could see the group sum and group counts formulas in the Formula Fields of Field Explorer. But for some reason, I dont see the group sum and group count formula fields in the "Create Running Total Field" window in order to summarize.

Do you know why they are not showing up ? And could you provide a solution to this ?
0
 
LVL 23

Assisted Solution

by:Ido Millet
Ido Millet earned 1000 total points
ID: 38767609
You can't do a Running Total on "Print Time" formulas (shared variables make any formula a Print Time (2nd pass) formulas).  Instead, you have to use variables in formulas to accumulate the group values into Grand totals.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 38768071
Change your group average formula

WhilePrintingRecords;
Global NumberVar GrandTotal;
Global NumberVar GrandCount;
Shared NumberVar GroupTotal;
SharedNumberVar GroupCount;
GrandTotal := GrandTotal + GroupTotal;
GrandCount := GrandCount + GroupCount;
GroupTotal / GroupCount

In the report header add a formula
WhilePrintingRecords;
Global NumberVar GrandTotal;
Global NumberVar GrandCount;
""

In the report footer calculate the overall average
WhilePrintingRecords;
Global NumberVar GrandTotal;
Global NumberVar GrandCount;
GrandTotal / GrandCount

mlmcc
0
 

Author Comment

by:pradeepdevineni
ID: 38768279
Thank you. That really worked.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String 2. Set the Stored Procedure Parameter to varchar(max)  --<---- This part here is the key to it's success Example:    @cst_key var…
How to increase the row limit in Jasper Server.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

721 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