# Sum of Each Group Total

I created a total under each group footer, how can I sum each group total and place it into report header?

Thanks,
Crystal ReportsProgramming

Last Comment
James0628
James0628

What kind of total?  If it's just a regular summary, you can just right-click on the field, select Insert > Summary and create a grand total.  The total field will be created in the report footer, but you can just drag&drop it into the report header.

James
If you need each group total in the report header you will have to use either a subreport or a cross tab.

mlmcc
rowfei

Here is the sample of each group number:

Group 1:

Item A
Item B
Item A
Item C

Group 2:

Item B
Item B
Item C

I use distinct count for each group. Since some item can be on the different group, if I use distinct count for total item, I am getting the much less total count.

That's why I am looking for a solution to sum of each group distinct count to make sure I am getting the right total count.

Thanks
That information changes the way it is answered.

YOu will only be able to show the total in the report footer unless you use a subreport.

Basic idea.
Name - DeclareVariables
``````WhilePrintingRecords;
Global NumberVar TotalCount;
TotalCount := 0;
''
``````

Add a formula to the group footer
Name - CalcTotal
``````WhilePrintingRecords;
Global NumberVar TotalCount;
TotalCount := TotalCount + DistinctCount({ItemField},{GroupField});
''
``````

Add a formula to the report footer
Name - DisplayTotal
``````WhilePrintingRecords;
Global NumberVar TotalCount;
TotalCount
``````

mlmcc
rowfei

Thanks, mlmcc.

I tried to add those formulas, the total shows on the report footer much less than the actual total. For testing purpose, I removed the  {GroupField}, the total is matched with distinct count of total items. Do you know where is wrong that I can't get the right total of each group?

TotalCount := TotalCount + DistinctCount({ItemField},{GroupField});

Thanks,
I assume you changed and used the actual fieldnames for the field and the group.

If you want the total for each group just insert a summary and use DistinctCount and put it in the group footer

mlmcc
rowfei

I might put the wrong group field name. Which group field name should I select? Currently I put the record name that I selected for the group. But the total on the report footer is incorrect.

If you right click the Item in the detail section can you insert a summary?
If so put it in the group footer.

Do those counts look correct?

No data needed

mlmcc
James0628

THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Programming

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts

TRUSTED BY