dmuun
dmuun

Reputation: 1228

Crystal reports - running total for specific groups

I have 4 groups and I only wanted to have running totals for 2 of them and show the total after the second group. Is there a way to do this?

Group1
DetailsA
 records...

Group2
DetailsA
 records...


TOTAL - SUM(records)

Group3
DetailsA
 records...

Group4
DetailsA
 records....

Upvotes: 1

Views: 12469

Answers (1)

user359040
user359040

Reputation:

There are a couple of ways of doing this:

(1) Set up a running total to sum the appropriate field - add it to a group footing section which is suppressed where the group is not group2.

or

(2) Add a higher level of grouping on a formula set to 1 for the existing groups 1 and 2, and as 2 for groups 3 and 4, then add a sum of the appropriate field to the group footing section for the formula group (which should be suppressed where the formula is not 1). To do so:

  • add a new formula field called TopGroup (for example).
  • give it a formula like:

    if {TableName.GroupField} = Group1 or {TableName.GroupField} = Group2 then 1 else 2 (substituting actual Group1 and Group2 values as appropriate).

  • Insert a new group on TopGroup. You will probably find that this is now the lowest level of grouping - open the Group Expert to make it the top level of grouping.

  • Right-click on your new Group Header #1 and select Suppress.
  • Drag and drop the field you want to sum into your new Group Footer #1. Right-click on it in the footer and select Insert > Summary... , select the appropriate summary operation (probably Sum) and Summary Location as Group #1, then click OK.
  • Drag the new summary field off the top of the field it summarised in the Group Footer #1 section, then replace the unsummarised data field with an appropriate text field - eg. Total: .
  • Enter the Section Expert, and set the Group Footer #1 to be conditionally suppressed where {@TopGroup} <> 1 . If you now preview your report, you should see the desired total between the end of Group2 and the start of Group3.

If it turns out you are likely to need to display the running total elsewhere in the report then I would suggest the first method, otherwise I personally would prefer the second.

Upvotes: 3

Related Questions