Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: how can I get the sum of fields in group Post Reply Post New Topic
Author Message
haivy
Newbie
Newbie


Joined: 18 Jun 2009
Online Status: Offline
Posts: 5
Quote haivy Replybullet Topic: how can I get the sum of fields in group
     Posted: 18 Jun 2009 at 4:20am
example:
fieldA fieldB
2 30 group1
2 10
5 12 group2
5 14
5 9 group3
8 1
8 9

the values of fieldA in a group are the same.
what i want is  to calculate fieldA of each group only once: 2+5+8
how can i do this and display the sum at the report header?
 
"running total fields" only sumarizes the first record!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Jun 2009 at 6:48am
subreport, and in the subreport you will need to use a formula to sum the field A values.  I would probably make a group in the subreport so that you can place the formula there.
 
Crystal has to read the records first, so the only way to get something like this in the report header is to have a subreport to force Crystal to read the data.  This will imply that your data will be read twice.  Once for the subreport and once for the rest of the report.
 
If you were getting your data from a stored proc, you could modify the stored proc to only report the value once per group then you could just do a sum of the field, which Crystal will perform in the report header.
 
HTH
IP IP Logged
haivy
Newbie
Newbie


Joined: 18 Jun 2009
Online Status: Offline
Posts: 5
Quote haivy Replybullet Posted: 19 Jun 2009 at 2:21am
thanks for your help.
i tried but it seems that dosen't work well.
liked the "running total field" in the report header, field A values only summarized once in the sub report....
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum