Avatar of rowfei
rowfei

asked on 

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

Avatar of undefined
Last Comment
James0628
Avatar of 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
Avatar of rowfei
rowfei

ASKER

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.
Add a formula to the report header
Name - DeclareVariables
WhilePrintingRecords;
Global NumberVar TotalCount;
TotalCount := 0;
''

Open in new window


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

Open in new window


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

Open in new window


mlmcc
Avatar of rowfei
rowfei

ASKER

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
Avatar of rowfei
rowfei

ASKER

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.

Thanks again for your help!!!
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?

Can you upload the report?
No data needed

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Blurred text
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.
See Pricing Options
Start Free Trial
Programming
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
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo