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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation of Average difference between records

Status
Not open for further replies.
Jun 30, 2003
3
GB
I have to report on the Mean Time Between Failure (MTBF) of a set of equipments in the factory. The data table has a record for each equipment with the date/time that the equipment failed eg :
EquipId DateTimeFailed
3PAS1 01-Feb-2003 15:00:00
3PAS1 02-Feb-2003 07:58:00
3PAS1 02-Feb-2003 22:00:03
3PAS1 04-Feb-2003 15:15:00

Over a period of time I want to calculate the average time between failures. Using the Previous function I can calculate and display in the detail section of a report the time between the current record and the previous record. However I cannot then use this field to summarise and calculate the average time between failures ie MTBF for each equipment ID.

What I want to see on the report is basically:
EquipId DateTimeFailed TimeSinceLastFail
3PAS1 01-Feb-2003 15:00:00
3PAS1 02-Feb-2003 07:58:00 16 (hours)
3PAS1 02-Feb-2003 22:00:03 14
3PAS1 04-Feb-2003 15:15:00 41
-----------------------------------
MTBF 23

Is there a way of achieving this?
Any help would be appreciated.

GreyHairedOne
(PS Numbers are made up)

 
You should be able to do this using three (or two if there is no "resetting" formulas).

The resetting formula, you'll need it sincce you are grouping, goes in the group header:

@reset
==========================================================
WhilePrintingRecords;
numbervar counter:=0;
numbervar accum:=0;
==========================================================

The second goes in the details band:

@accumulator
==========================================================
EvaluateAfter ({@formula.you.created.to.get.times});
numbervar counter:=counter;
numbervar accum:=accum+{@formula.you.created.to.get.times});
==========================================================

The final formula goes into the group footer:

@display
==========================================================
WhilePrintingRecords;
numbervar counter;
numbervar accum;

accum/counter
==========================================================

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top