Crystal reports - running total for specific groups

戏子无情 提交于 2019-12-13 01:28:55

问题


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....


回答1:


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.



来源:https://stackoverflow.com/questions/8350764/crystal-reports-running-total-for-specific-groups

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!