Print Page | Close Window

Report Total from Subreport to Main Report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22580
Printed Date: 30 Apr 2024 at 2:01pm


Topic: Report Total from Subreport to Main Report
Posted By: rcoxe
Subject: Report Total from Subreport to Main Report
Date Posted: 20 Apr 2018 at 2:31am
I have a sales report (main report) that brings in some subreports to show needed information. This would be things like new customers and sales from these new customers. The main report is grouped by sales person and there is a group footer showing the totals for each sales person. In each of these subreports I have shared variables that I pass to the main report to show these group totals.

My problem is that I am trying to have the report footer show grand totals for all sales people combined. I calculate these totals by using running totals and have created the formulas to share the variable up the main report. When I open the subreport these grand totals are correct but when I look at the main report it is only calculating the information for the last sales person instead of adding information from all sales people.

My subreports are in the details section and these formulas are the report footer section of the main report.

What is causing this and how do I fix it? I am using Crystal 11.

Thank you for the help.



Replies:
Posted By: lockwelle
Date Posted: 23 Apr 2018 at 10:21am
Since I don't know exactly how the report is put together, what I would be looking for, given the description, is what variable is being used to sum up the shared variables?

If the report footer is only showing the results for the last person/group, it sounds like there should be another variable (shared or global) that would sum up the results from each display of the shared variables.

Hoping that this make sense?


Posted By: rcoxe
Date Posted: 25 Apr 2018 at 3:35am
All variables are shared variables. There are no global variables used.

The subreport is formatted like this:
- Group header 1A contains the sales person's name
- Group header 1B contains the column headers
They are both grouped by the sales person's name.
- Group header 2 contains no data but is used to group by customer code.
- Details contain row information of new customers
- Group footer 2 no data
- Group footer 1 contains the shared variables (using running totals) that I use to pass up to the main report and show totals for each sales person individually
- Report footer contains different shared variables (using different running totals) created in this subreport

The running total used in the shared variable for the group footer, to sum each sales person, is based on the a formula to pick out the new customers (minimum month of invoice per customer = month of report in parameter) and it resets on change of sales person.

The running total used in the shared variable for the report footer, that is supposed to sum up everything for all sales people, is set to evaluate each record and never reset. This results in the correct total when viewing the subreport by itself, but I view the main report then it is no longer correct.

Each of these running totals and shared variables are unique.

So the subreport would look something like this:
Sales Person A
Cust #1 | ABC Company | Invoice #001 | 4/1/2018 | $100.00 total
Cust #2 | XYZ Company | Invoice #002 | 4/2/2018 | $50.00 total
Sales Person A Summary: 2 New Customers | $150.00 new sales

Sales Person B
Cust #3 | John's Plumbing Co. | Invoice #003 | $40.00 total
Cust #4 | Bob's Heating Co. | Invoice #004 | $70.00 total
Cust #5 | Joe's Hardware Co. | Invoice #005 | $60.00 total
Sales Person B Summary: 3 New Customers | $170.00 new sales

Subreport Footer
Summary:
Total new customers: 5
Total new sales: $320.00

If I was to view the main report with the information above, the report footer where I have placed the shared variable that correspond to the report footer for the subreport, the main report footer would look like this because for some reason it is only seeing data for the last sales person:

Total new customers: 3
Total new sales: $170.00

The main report is designed:
- Group header 1 is grouped by the sales person name (same field used as subreport Group header)
- Details A-D each contain a different subreport. My problem so far lies with the subreport in detail A. I have not tried details B-D yet.
- Group footer 1 contains shared variables from the group footer in the subreport that sums up each sales person individually. This works fine.
The report footer contains the shared variables from the subreport that correspond to the subreport footer.

Is it possible my running total for the subreport footer is not working correctly in the main report?

Thank you for the help.


Posted By: lockwelle
Date Posted: 25 Apr 2018 at 11:18am
the running total that never resets is in the subreport or the main report? If it is in the subreport, it resets every time the subreport runs, because it is a new report every time it runs.

What I typically do is have a shared variable in a GF1 that would update the variables for the entire report. It doesn't sound like this is the case.

I might have gotten it wrong from reading the description.

HTH


Posted By: rcoxe
Date Posted: 25 Apr 2018 at 11:46am
The running total that never resets is located in the subreport. I am calling this running total w/ formula that is located in the report footer of the main report. Since it is located outside of the subreport, shouldn't this running total sum up everything after the subreport has finished running for each sales person?

How would this shared variable give me the sum for the entire report? Is this shared variable you're suggesting located in the subreport or the main report?

Thanks




Print Page | Close Window