Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: My three formula trick isn't working Post Reply Post New Topic
Author Message
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Topic: My three formula trick isn't working
     Posted: 28 Sep 2010 at 8:03pm
Hi All
 
I am using Crystal XI to produce a report that will give me the usage for date range. My report is as follows;
 
GH1 {machine no}
Details: {reading date} {trigger reading} {trigger code} {@declarehours}
 
Which displays as;
3212
 
5/7/10     13050  HRS
6/7/10     13059   HRS  9
9/7/10     13081   HRS  22
13/7/10   13093   HRS  12
 
3213
 
4/7/10    12778  HRS
5/7/10    12784  HRS  6
8/7/10    12805  HRS  21
14/7/10  12849  HRS  2
 
I need to work out how many HRS this machine has done within a date range and have tried to use the three formula trick to set up a 'running total', but it isn't working. The formulas I have used are;
 
@declarehours in details
whileprintingrecords;
numbervar hours;
hours:={trigger reading}-previous{trigger reading};
 
@resethours in GH1
whileprintingrecords;
numbervar hours:=0; (this isn't resetting)
 
I need to display the sum of @declarehours in GF1. I have used a variety of formuals to 'sum' @declarehours but it keeps giving me the las @declarehours doubled. ie; 3212, 24 and 3213, 4.
 
I beleive there is something wrong in my @declarehours as it is not resetting.
 
I hope this coherent and am very grateful for any suggestions.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 Sep 2010 at 3:03am
I don't think it is the reset...it is the previous...it will cross group boundaries as you told it to read the previous (kind of redundant).
 
What I would try is to create another variable and have it hold the previous value, and reset it in GH1 as well.  Something like:
 
@resthours
shared numbervar hours := 0;
shared numbervar prevHour := 0;
 
@declarehours
shared numbervar hours;
shared numbervar prevHour;
 
hours:={trigger reading}-prevHour;
prevHour := {trigger reading};
 
hours  //if you want to display the hours.
 
 
HTH
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 13 Oct 2010 at 2:23pm
lockwelle
I tried your suggestion as follows;
 
GH1  {machine_no}   {@resethours}   {@resetprevhours}
Details  {reading_date} {trigger_reading}  {trigger_code}  {@declareprevhours}  {@declarehours}
 
 
Which displays as;
 
3212
5/7/10   13050  HRS  13050   13050
6/7/10   13059  HRS  13059           9
9/7/10   13081  HRS  13081         22
 
 
3213
4/7/10   12778  HRS  12778  12778
5/7/10   12784  HRS  12784          6
8/7/10   12805  HRS  12805        21
 
 
My first record is not resetting to zero.
 
This is all on the main report. Basically what I want to do is have a running total that subtracts instead of adds.
 
Thanks for your time.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Oct 2010 at 3:35am
the more I look at it, I think that the reset for one of them should not be 0, but the number of hours in the record, so that when you subtract you get 0.
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 19 Oct 2010 at 3:15pm
lockwelle
 
I changed the @resetprevhours to;
 
numbervar prevhours:={trigger_reading} and, with a little more tweaking, all is right in my world.
 
Thanks heaps
 
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