Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Running Total Post Reply Post New Topic
Author Message
pnini1000
Newbie
Newbie


Joined: 21 Jul 2010
Online Status: Offline
Posts: 14
Quote pnini1000 Replybullet Topic: Running Total
     Posted: 01 Sep 2010 at 3:35am

Hi,

I have to sum a field but I have 2 conditions:
 
1. on change of  field
2. when a boolean field equal true
 
I used running total. in evaluate I can choose "on change of field" and in formula I can write: "field=true".
but I can't choose both of them.
 
can I write a formula that do all the conditions?
 
help me!
 
thanks,
pnini 1000
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Sep 2010 at 5:28am
yes, you can write a formula...typically they come in sets of 3.
 
1 in group header, which resets the value, like:
shared numbervar aSum:=0;
""  //hides the output of 0
 
1 in the group footer to display the value:
shared numbevar aSum
 
1 in the details that does the work:
shared numbervar aSum;
 
if {table.boolean} And {table.Change} <> Previous{table.Change} then
  aSum := aSum + {table.ValueToSum};
 
"" //to hide the output (remove to debug)
 
 
if you get the general idea, so you should be able to modify as needed to suit your needs.
 
HTH
IP IP Logged
pnini1000
Newbie
Newbie


Joined: 21 Jul 2010
Online Status: Offline
Posts: 14
Quote pnini1000 Replybullet Posted: 02 Sep 2010 at 1:21am
thank you!
it's work well but in the first time it doesn't display value because there is no previous record.
 
by the way, I try to use this formula in running total and it's do the same-without the first time.
 
you have a idea for me?
 
pnini1000


Edited by pnini1000 - 02 Sep 2010 at 2:21am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 02 Sep 2010 at 7:21am
try initializing the value to 0, and test if you are on the first record...OnFirstRecord, and react accordingly
IP IP Logged
pnini1000
Newbie
Newbie


Joined: 21 Jul 2010
Online Status: Offline
Posts: 14
Quote pnini1000 Replybullet Posted: 04 Sep 2010 at 7:49pm
It worked out.
 
thank you,
pnini1000
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