Print Page | Close Window

Summation in formula field

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17092
Printed Date: 04 May 2024 at 9:29am


Topic: Summation in formula field
Posted By: Douang
Subject: Summation in formula field
Date 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 ( mailto:%7b@SharedRate - {@SharedRate }, {ServiceInfo});
 
Help please!
 
Thanks!
 



Replies:
Posted By: kevlray
Date 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 ( mailto:%7b@SharedRate - {@SharedRate }, {ServiceInfo});


Posted By: Abhi
Date 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







Posted By: Douang
Date 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.



Print Page | Close Window