Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Crystal Report Grand Total in Main Report from Sub Reports

Posted on 2016-10-13
6
Medium Priority
?
143 Views
Last Modified: 2016-10-14
I need some help on how to get a Grand Total of Vendor Spend from the Vendor Spend subreport into my main report.  Ultimately, I want to get the overall percentage of Total NC Dollars vs. Vendor Spend.

Please realize that the Vendors listed will change based on whether or not there was an Nonconformance (NC) written up for them and/or the time frame I am running the report for.

I'm at a loss as to what and where I would enter variables for this.
--mail-staylor--Custom-Reports-uniPo.rpt
0
Comment
Question by:ITworks
[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
  • 4
  • 2
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 41842388
Basic method

In the main report add a formula to the report header
WhilePrintingRecords;
Shared Numbervar VendorSpend;
''

Open in new window


In the subreport add a formula to set the value.  Change 100 to whatever formula or field you use to calculate the value.

WhilePrintingRecords;
Shared Numbervar VendorSpend;
VendorSpend := 100;
''

Open in new window


To use the value in the main report add a formula.  The key is this formula has to be in a section after the section the subreport is in.  The reason is the subreport is the last object rendered/evaluated in a section so formulas in that section are calculated before the shared value is updated.

A formula to display the Vendor spending from the subreport
WhilePrintingRecords;
Shared Numbervar VendorSpend;
VendorSpend

Open in new window


mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 41842395
I looked at the report.  I don't see a problem unless the values are incorrect.

I think your formula in the group footer has the division reverses

WhilePrintingRecords;
Shared NumberVar SubreportTotal;
If  Sum ({@Total NC Cost}, {@Vendor})  = 0 then
    0
Else
    SubreportTotal  / Sum ({@Total NC Cost}, {@Vendor})  * 100

Open in new window


mlmcc
0
 
LVL 4

Author Comment

by:ITworks
ID: 41842517
I did something wrong.  Instead of getting the grand total, I'm getting the total of the last vendor on the page right before the report footer.
--mail-staylor--Custom-Reports-uniPo.rpt
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 101

Expert Comment

by:mlmcc
ID: 41843071
The formula should be

WhilePrintingRecords;
Shared NumberVar SubreportTotal;
If Sum({@Total NC Cost}) = 0 then
0
else
SubreportTotal / Sum ({@Total NC Cost}) *100

Open in new window


mlmcc
--mail-staylor--Custom-Reports-uniPo.rpt
0
 
LVL 4

Author Comment

by:ITworks
ID: 41843806
I must not have explained myself correctly.  I'm not getting the GRAND TOTAL of all the Vendor Spends from my subreport in my Main Report.  The current formula gives me the total spend for the last vendor on any given page.  

I want the totals for all vendors, so on the example I attached Called "Example 1" it shows the Grand Total of $68,440.44 (in Lime Green).  That's the same as the total vendor spend for my last vendor, 1206604 - Dayang Fastener Factory.  What I need it to display is the Grand Total of $94,246.76, which is $16,508.70 + $9,297.62 + 0 + $68,440.44
C--Users-staylor-Desktop-Example-1.pdf
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 41843888
I updated the report to calculate the grand total

mlmcc
--mail-staylor--Custom-Reports-uniPo.rpt
1

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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