Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Summation in formula field Post Reply Post New Topic
Author Message
Douang
Newbie
Newbie


Joined: 15 Nov 2011
Location: United States
Online Status: Offline
Posts: 12
Quote Douang Replybullet Topic: Summation in formula field
    Posted: 24 Jul 2012 at 4:14am
I have a formula field that I want to keep summing on field Rate.  Rate is displayed on my report.
 
The scenario is: I have two records coming in to the report.
 
Record #1 ServiceInfo = 111122223333 , Rate= 170.00
Record #2 ServiceInfo = 111122223333 , Rate= 170.00
 
The report is group by ServiceInfo.  So, the report displays only one record which is what I want.  I also want to keep summary of the rate.  So, I created a formula field to add up the rate.  In this case, my formula TotalRate should add up to be a total of 170 but my report display 340.
 
My formula field looks like this:
 
Whileprintingrecords;
Numbervar TotalRate;
TotalRate := TotalRate + Sum ({@SharedRate}, {ServiceInfo});
 
Help please!
 
Thanks!
 


Edited by Douang - 24 Jul 2012 at 4:34am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 24 Jul 2012 at 5:38am
This is probably not the best solution, but it should work.  I am assuming that you want to only add when the service info field changes.

Whileprintingrecords;
Numbervar TotalRate;
if next({serviceinfofield})<>{serviceinfofield} then
TotalRate := TotalRate + Sum ({@SharedRate}, {ServiceInfo});
IP IP Logged
Abhi
Newbie
Newbie


Joined: 23 Jul 2012
Online Status: Offline
Posts: 12
Quote Abhi Replybullet Posted: 24 Jul 2012 at 5:49am
I feel you're getting duplicate records. Try to find a filter to get unique records.
Thanks!
Abhi





IP IP Logged
Douang
Newbie
Newbie


Joined: 15 Nov 2011
Location: United States
Online Status: Offline
Posts: 12
Quote Douang Replybullet Posted: 24 Jul 2012 at 8:34am
Yes I have two records with the same ServiceInfo.  If that's the case, I only want to add one Rate to my TotalRate formula field.  In this case, my TotalRate should be 170 not 340.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.008 seconds.