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
934 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
  • 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hi, In my previous Article  (http://www.experts-exchange.com/Database/Reporting/A_15199-Introduction-to-Microstrategy.html)I discussed some basic understanding of Microstrategy that how we can get in Intro of Microstrategy (MSTR). Now it's tim…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

706 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

19 Experts available now in Live!

Get 1:1 Help Now