Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Trying Add Highest and Lowest Values from a field Post Reply Post New Topic
Author Message
DJLeadfoot
Newbie
Newbie


Joined: 04 Sep 2013
Online Status: Offline
Posts: 12
Quote DJLeadfoot Replybullet Topic: Trying Add Highest and Lowest Values from a field
     Posted: 28 Oct 2013 at 1:54am
Record setA
Record ID          TimeSlice
     A1                         520
     A2                         460   *
     A3                         550
     A4                         700   *     
     A5                         650

Need to subtract the highest value in the range from the lowest value in the range.
E.g. 700 - 460 = 240
240 is the result of the calculation that I want to print out per Record set

Report Output (Detail line for Group Footer if that works better ... not sure about best approach)
Set A      Result = 240

Any help is greatly appreciated
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Oct 2013 at 4:48am
well, my favorite is the variable...they come in sets of 3 formulas (probably could use a running total as well)

reset: usually in a group header
shared numbervar hi:=0;
shared numbervar low:=1000000;
""//hide the reset value

increment: usually in details:
shared numbervar hi;
shared numbervar low;
if {table.field} > hi then hi:={table.field};
if {table.field} < low then low:={table.field};
"" //again to hide the output

display: usually in a group footer
shared numbervar hi;
shared numbervar low;
hi-low

HTH
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 28 Oct 2013 at 6:51am
you could also try a formula like
maximum(TimeSlice)-minimum(TimeSlice)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Oct 2013 at 7:05am
never thought of that...guess I just don't use Max/Min too often on a report. It would seem to be a simpler solution than mine.
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