Print Page | Close Window

Minimum and maximum function.

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14108
Printed Date: 03 May 2024 at 11:48pm


Topic: Minimum and maximum function.
Posted By: andrewsimon
Subject: Minimum and maximum function.
Date Posted: 16 Aug 2011 at 11:51pm
I want to display first in last out of employee per day in crystal report.
The problem is that ,the IN and OUT entry is identified by the reader,
ie,
READER=1 for  IN entry
REDER=2 for the Out entry
 
I'm using this formulas for the first in and last out
 
DateTimeVar Time1 :=minimum({EVENTS.EVENT_TIME_UTC},{@EDATE});
 
DateTimeVar Time1 :=maximum({EVENTS.EVENT_TIME_UTC},{@EDATE});
the problem is that ,there is no way to identify,the value is correct for
Entry and exit.
some times,the maximum({EVENTS.EVENT_TIME_UTC},{@EDATE}) is occured in the READER=1
Is there any way to find, the minimum time for REDER=1
and
Maximum Time for READER =2
 
 
 


-------------
bbbbb



Replies:
Posted By: lockwelle
Date Posted: 17 Aug 2011 at 2:26am
as long as you are not grouping on it, and the results can go in the group footer...
 
formulas with shared variables, something like:
(detail section - incrementor)
shared datetimevar dtIn;
shared datetimevar dtOut;
 
if dtIn > {table.timeField} and {table.reader} = 1 then
   dtIn := {table.timeField};
 
if dtOut < {table.timeField} and {table.reader} = 2 then
   dtOut := {table.timeField};
 
"" //hides the output
 
group footer - display:
2 formulas
shared datetimevar dtIn;
dtIn
 
shared datetimevar dtOut;
dtOut
 
group header - reset...
it's really just about setting the initial values to be opposites of the what you want...
shared datetimevar dtIn := "12/31/2200";
shared datetimevar dtOut := "1/1/2000";
"" //again to hide the output
 
HTH


Posted By: DBlank
Date Posted: 17 Aug 2011 at 4:08am
As Lockwelle knows I prefer Running Totals to Variable formuals so I will give you that version as well.
 
You can use a conditional formula to tell it which records to evaluate
 You will need 2 RTs
 
Name = Min_In
Field to summarize=EVENTS.EVENT_TIME_UTC
Type of Summary = Minimum
Evaluate= use a formula
table.READER=1
reset= on Change of Group @Edate (this is based on how you wrote your code above)
place in group Footer (Rts do not work in headers)
 
Name = Max_Out
Field to summarize=EVENTS.EVENT_TIME_UTC
Type of Summary = MAximum
Evaluate= use a formula
table.READER=2
reset= on Change of Group @Edate (this is based on how you wrote your code above)


Posted By: andrewsimon
Date Posted: 18 Aug 2011 at 1:17am
Thank you Dblank.It is working perfectly.....

-------------
bbbbb


Posted By: rami
Date Posted: 13 Jan 2012 at 8:47am
Hi Andrewsimon

i guess i have the same lenel system which you succeed to create this report may i ask you to help me creating this report but i need to get the first in and last out from all readers


Posted By: andrewsimon
Date Posted: 15 Jan 2012 at 1:26am
You just omit the condition table.Reader.

-------------
bbbbb


Posted By: rami
Date Posted: 19 Apr 2012 at 9:14am
HI,

its not working yet, please can you copy and paste your code here



Print Page | Close Window