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!

Averages on Calculated fields 1

Status
Not open for further replies.

whitd01

Technical User
Apr 27, 2001
17
0
0
US
I have created a report that determines room turnover times by room and then displays the data on a report. I would like to now generate an average for each room of these "turnover" times but since they are formulas with calculated field I am running into a problem. Anyone doing anything like this, here is a sample of the formula that I am using for the turnover times :

IF {case_record.room_mnc} = Previous ({case_record.room_mnc}) and
{case_record.cr_prdate} = Previous ({case_record.cr_prdate})
THEN
IF {v_CRA_OR_Patient_Times.time_pat_in_room} >= Previous ({v_CRA_Intraop_Drsg_ESU_Plate_Site.time_pat_out_of_room})
Then ((Truncate( {v_CRA_OR_Patient_Times.time_pat_in_room} /100)*60)+
(ToNumber(Right(ToText( {v_CRA_OR_Patient_Times.time_pat_in_room}/100),2))))-
((Truncate( Previous ({v_CRA_Intraop_Drsg_ESU_Plate_Site.time_pat_out_of_room}) /100)*60)+
(ToNumber(Right(ToText( Previous ({v_CRA_Intraop_Drsg_ESU_Plate_Site.time_pat_out_of_room}) /100),2))))

ELSE
(1440 - (Truncate( Previous ({v_CRA_Intraop_Drsg_ESU_Plate_Site.time_pat_out_of_room}) /100)*60+
ToNumber(Right(ToText(( Previous ({v_CRA_Intraop_Drsg_ESU_Plate_Site.time_pat_out_of_room}) /100)),2)))) +
(Truncate( {v_CRA_OR_Patient_Times.time_pat_in_room} /100)*60 +
ToNumber(Right(ToText(( {v_CRA_OR_Patient_Times.time_pat_in_room} /100)),2)))
ELSE
0
 
You can use a variable. I'm not sure of your report structure, but if you want an average per room, let's assume you have a group on {table.roomno}. Then you would place a formula like the following in the group header:

//{@reset}:
whileprintingrecords;
numbervar sumformula := 0;

//{@accum} to be placed in the detail section:
whileprintingrecords;
numbervar sumformula := sumformula + {@yourformulaabove};

//{@displ} to be placed in the group footer:
whileprintingrecords;
numbervar sumformula;

sumformula/distinctcount({table.patientno},{table.roomno})

I'm not sure what belongs in the denominator--whether you are dividing times by the number of patients, but you would at least use the above syntax.

-LB
 
Thank you so much, this really helped out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top