Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Tips and Tricks
Message Icon Topic: Sum of Formula field Post Reply Post New Topic
Author Message
OlgaS
Newbie
Newbie


Joined: 02 Dec 2011
Location: United States
Online Status: Offline
Posts: 7
Quote OlgaS Replybullet Topic: Sum of Formula field
    Posted: 02 Dec 2011 at 7:34am
Hi Experts,
 
I need your help. I have a formula field (@ep),  and i need to calculate a sum of this field: sum(@ep). When i use 'Insert', I do not see formula fields. Field @ep is numeric, not string. What should I do?
 
Thank you
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Dec 2011 at 9:05am
if the formula is calculating something that is not in the raw the data (ie, it is not summing up a field, but is say adding a field conditionally) then you cannot use the built in aggregate functions.
 
you could track the value yourself by adding something like this to the @ep:
shared numbervar rtTotal;
local numbervar thisTotal;
 
if ..... then .....
 
thisTotal := original value of @eps
 
rtTotal := rtTotal + thisTotal;
 
thisTotal   // CR always prints the last value it is given
 
then when you want to display the total, you would create a formula like:
shared numbervar rtTotal;
rtTotal
 
and if the value should ever by reset, then where you want the total to reset you would have something like:
shared numbervar rtTotal := 0;
"" //hides the reset from displaying
IP IP Logged
OlgaS
Newbie
Newbie


Joined: 02 Dec 2011
Location: United States
Online Status: Offline
Posts: 7
Quote OlgaS Replybullet Posted: 07 Dec 2011 at 6:31am
Thank you
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.032 seconds.