Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average of Elapsed time

Status
Not open for further replies.

michelin

Technical User
Dec 18, 2011
38
US
I have a difficult time to average "minimum" times:
datediff("n",Minimum ({Assigned Time }, {Incident}),Minimum ({AtScene}, {Incident}))

I have two incidents:
Incident I
Unit Time Assigned Time AtScene
A 00:05:00 00:06:00
B 00:01:00 00:10:00

Incident II
Unit Time Assigned Time AtScene
A 00:10:00 00:14:00
B 00:20:00 00:23:00

I needed to know what is the difference between the earliest time assigned and earliest time atscene for each incident separately (using formula datediff("n",Minimum ({Assigned Time }, {Incident}),Minimum ({AtScene}, {Incident}))), but now I need to average both incidents.
 
Calculate your minimum and maximum times, add them and divide by 2.
 
I don't think i'm following you...calculate minimum of what? maximum of what?
would you mind to give me an example using my data?
I apologize about any inconvenience.
 
The formula you posted shows the minimum elapsed time. A silimar formula would give you the maximum elapsed time. Add them together and divide by two.

If your formula is not iving you what you want currently, I'd try this approach using shared variables.

formula 1 @init goes in report header
shared numbervar emin :=9999999;
shared numbervar emax :=0

formula 2 @findmin goes in detail section
shared numbervar emin;
if datediff('n',{Assigned},{AtScene}) < emin
then emin := datediff('n',{Assigned},{AtScene})
else emin := emin

formula 3 @findmax goes in detail section
shared numbervar emax;
if datediff('n',{Assigned},{AtScene}) > emax
then emax := datediff('n',{Assigned},{AtScene})
else emax := emax

formula 4 @gotmin goes in report footer
shared numbervar emin

Formula 5 @gotmax goes in report footer
shared numbervar emax

Now you have your minimum and maximum times. to get the average ({@gotmax}+{@gotmin})/2
 
I get an error using formula 2 for emin: A number, currenct amount, boolean, date, time, date-time, or string is expected here. Am I doing something wrong?

I really really appreciate your answer!
 
like I would like to summarize the elapsed time... but i get an error, that this formula can't be summarized.
 
@Charlyi. never mind. i got it! i used the tree formula trick. thank you very much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top