Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

diplaying group grand totals on each page

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
CR8.5.
I need to show grand totals of each region on each page under each division. I am showing each division on a new page. Here is test data in my scenario:
RegionA
Division1 200
Division2 300
Division3 100
RegionB
Division2 100
Division5 75
RegionC
Division4 340

Format required is:
---------------
Page:1
RegionA
Division1
Total For Division1:200
Grand Total for RegionA:500
------------------------
Page2:
RegionA
Division2
Total For Division2:300
Grand Total for RegionA:500
-------------------------
Page:3
RegionA
Division3
Total For Division3:100
Grand Total for RegionA:500
------------------------
Page:4
RegionB
Division2
Total For Division2:100
Grand Total for RegionB:175

I hope you should have a good idea of the report layout by now. Is there a way to do it easily?


 
This looks like a subreport to me.
Create a subreport which produces region totals and drop this into the division group footer, linking it to the main form on region.

An alternative would be to build an array of totals while reading records and get the relevant total as you are printing records. (This would be faster , but in my opinion the subreport is easier to implement)
 
I have the subreport but it is taking long time to load and the performance is not acceptable to the client.
 
If you group by Division within Region, you should be able to get group totals for both. (Note that Crystal regards a Grand Total as a total for the whole report.)

If you use summary totals, these will be available at once. It ought to be OK to show the Regional total as part of the Division group footer, though I've never actually done this.

On the general topic of totals, there are several methods in Crystal: running totals, summary totals, grand totals and variables. Right-click on a field and choose Insert to get a choice of Running Total, Summary and Grand Total.. Or else use the Field Explorer, the icon that is a grid-like box.
Running totals allow you to do clever things with grouping and formulas. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.
Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say.
Grand totals are much like summary totals, but for the whole report rather than groups. Note that summary totals include an option to have a grand total calculated on the same basis.
Variables are user-defined fields. I don't use them, except for shared variables to pass data from a subreport back to the main report. You can also use variables to show page totals. For normal counting I find running totals or summary totals much easier.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Hi Madawc, I have no problem in getting the Region Grand Totals, but the problem is I am not able to display them on each page, below grand totals of each division. I can do that through a subreport but as I mentioned earlier it is not acceptable.
 
Try showing summary totals via a formula field. I tried it, and found that it would display them correctly, even in the page footer.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
I just tried to add the formulas and I don't knowwhy some formulas are not returning any values where as some are.
Like for exp:
//@distCount
if {Tabl1.QTY}>0 And
{Table1.Category}='Plastics' or
{Table1.Category}='Elastics' Then
DistinctCount({Table1.ID},{Table1.Region})
Is this formula corrct? I
 
To get the regional total at the division level, write a formula:

sum({table.amt},{table.region})

Place this in your division group footer next to your division total.

As to your other question, you should write the formula like this (assuming you don't have duplicates):

//{@PlasorElas} to be placed in the detail section:
if {Tabl1.QTY}>0 And
{Table1.Category}='Plastics' or
{Table1.Category}='Elastics' Then 1

To summarize this at the division level, right click on it and insert a summary (SUM, not count). For a summary at the regional level to be displayed in the division group footer, create a second formula:

sum({@PlasorElas},{table.region})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top