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
950 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 22

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 22

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 22

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 100

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Problem Statement In an SAP BI BO Integration project when a BO universe is built on a BEx query, there can be an issue of unit & formatted value objects not getting generated in a BO universe for some key figures. This results in an issue whereb…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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