Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sum if field has same value with previous record Post Reply Post New Topic
Author Message
dylan73ph
Newbie
Newbie


Joined: 15 Apr 2009
Online Status: Offline
Posts: 3
Quote dylan73ph Replybullet Topic: Sum if field has same value with previous record
     Posted: 15 Apr 2009 at 1:22am
hi,

how can i sum my amount field if this is the case?

person  income1     income 2       expense 1      expense 2
A,            1.5             2.5                    1.0               1.0 
B             2.0            1.0                    0.5               1.50            
B             1.75          3.0                    2.0               0.75

C             1.4             1.0                    0                    0

i'm using a stored proc that produces several duplicates like in the case above which have 2 records of "B" person.

my report should look like this:

person    total income
A               2.0
B               3.0
C               2.4

can anyone help? thanks.


IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Apr 2009 at 6:44am
Not sure how you get 3, but you can use a shared variable.  reset it to 0 in the group header, update the values in the details section, and display it in the group footer. 
 
Since you only report on the summary, this should work.  for that matter, it looks like you can display group footer info and get what you want without the shared variable, as long as you are grouping by the person.
 
IP IP Logged
dylan73ph
Newbie
Newbie


Joined: 15 Apr 2009
Online Status: Offline
Posts: 3
Quote dylan73ph Replybullet Posted: 15 Apr 2009 at 6:56pm

oh, i havent indicated in my first post how i got the total income.

the total income = income1 + income2 - expense1 - expense2
 
that's why for person B, it's 3.0.
 
if i group it by person, isn't it the spacing of the report will be different? i would like my report to be spaced like a detailed report.Smile
 
can it be done?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Apr 2009 at 7:54pm
Group on person
Use a formula to get your sum per row (income1 + income2 - expense 1 -expense 2)
Sum the formula field at group level 1and place on g header
Suppress the details to handle your spacing question
IP IP Logged
dylan73ph
Newbie
Newbie


Joined: 15 Apr 2009
Online Status: Offline
Posts: 3
Quote dylan73ph Replybullet Posted: 15 Apr 2009 at 11:50pm
wow! thanks. it works!
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