Click to See Complete Forum and Search --> : Calculating average from a number of records


nickyjacob
October 18th, 2005, 07:23 AM
I have a table in my database that records project details.
Two fields that I have are DateOpened & DateClosed.

I need to be able to calculate the average of the total time in days projects have been opened
.
This will give me the days opened for one project (DateClosed-DateOpened)
I am not able to calculate this for a number of projects.

Also, if the date closed field is blank then this project should not be calculated

der_krahe666
October 18th, 2005, 05:52 PM
You must have first the total of days & of course the total of proyects, to count the total of proyects that I suppouse that you have in a group just type this formula:

NumberVar Count;
If Not OnFirstRecord Then
If previous (id_proyect_field) = id_proyect_field Then
Count:= Count + 1
Else
Count:= 1
Else
Count:= 1


Lay this formula in detail section and type the next formula to put it in the group footer


NumberVar Count;
WhilePrintingRecords;
Count:= Count;
Count

Those tow easy formulas give you the number of proyects, on the other side, take the diference between your openday and closeday fields and sum them.

To finish, do it: TotalOfDays / Count

This last action is in the report footer.

I hope this help you