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
960 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 250 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 250 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
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…

624 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