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

Calculating average

Status
Not open for further replies.

silck

MIS
Jul 1, 2002
13
US
I am trying to calculate the average # of days per examiner based on policy numbers but am having problems. For each policy, I calculate the # of business days it takes from time received to the first time action was taken. My formula is as follows:
{@days_intial}
WhilePrintingRecords;
DateVar Start := date({uvw_Recd_STD_LTD.newEnterDate});
DateVar End := date({@Change_date});
NumberVar Weeks;
NumberVar Days;
NumberVar Hol:= 0;

//Figure the number of Calendar "Rows" involved and count 5 days for each:
Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;

//Adjust the first and last weeks based on when in the week you start and end
Days := DayOfWeek(End) - DayOfWeek(Start) + 1

+ (if DayOfWeek(Start) = 1 then -1 else 0) //adjust for starting on a Sunday:

+ (if DayOfWeek(End) = 7 then -1 else 0); //adjust for ending on a Saturday:

//Adjust for Holidays in the period between the start and end dates:
//2004:
if Date(2004,01,01) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,01,19) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,05,24) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,07,05) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,09,06) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,11,25) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,11,26) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,12,23) in start to end then Hol:= Hol+1 else Hol:= Hol;
if Date(2004,12,24) in start to end then Hol:= Hol+1 else Hol:= Hol;

//Assemble the adjusted work days
Weeks + Days - Hol


In order to get the first time action was taken, the below formula is used:
{@Change_date}
if next({uvw_svctime_hist.STATUS}) = 'initial'
then {uvw_svctime_hist.CHANGE_DATE}
else
next ({uvw_svctime_hist.CHANGE_DATE})


The formula I'm trying to use to calculate average based on examiner is:
{@Average}
average({@days_intial}, {uvw_Recd_STD_LTD.examiner})

But because I have the {@Change_date} included in the {@days_intial} it doesn't work.

Any suggestions would be greatly appreciated!

~Kim
 
Which Crystal? If you are able to use Running Totals, it is well worth learning to use them. Do a couple of experimental reports, get familiar with the methods and then apply then to real business problems.

Madawc Williams
East Anglia, Great Britain
 
Crystal 8.5
I have already looked at that route and it will not allow me to use running totals for that.

thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top