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!

I have a report that's showing the

Status
Not open for further replies.

newbie0423

IS-IT--Management
Oct 29, 2012
103
US
I have a report that's showing the average time for all cases done in the Operating Room. There are several doctors associated with this report. I have a formula that show the total average. I would like to be able to find the average per doctor.

WhilePrintingRecords;
Global NumberVar TotalHours;
Global NumberVar WorkOrderCount;


TotalHours / WorkOrderCount
Dr. Jones 50
Dr. JOnes 30
Dr. Jones 20
case count3 Average time

Dr. Smith 20
Dr. Smith 30
Dr. Smith 10
Case Count3 Average time

Dr. Brown 25
Dr. Brown 50
Dr. Brown 25
Case Count2 Average time

Total Count9 Average Mins 29
 
You would do the same sort of thing as you're doing, except that you'll rename the variables to something like DrHours and DrCases and then reset them at the start of every doctor - something like this:

Code:
WhilePrintingRecords;
NumberVar DrHours;
NumberVar DrCases;

If OnFirstRecord or {table.dr_id} <> previous({table.dr_id}) then
(
  DrHours := 0;
  DrCases := 0;
)
<add the rest of your formula here.>

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Thank you so much for your reply. I have been playing around with different formulas to no avail. I just tried the formula you suggested, but it is returning 0.00. Would you be able to give me more information when you say <add the rest of your formula here>


The only other formulas I'm using are to get my turnover times:

if OnfirstRecord then
0
Else if Date({v_basic_case_rec_data.cr_prdate}) <> Date(Previous({v_basic_case_rec_data.cr_prdate}))then
0
Else if {v_basic_case_rec_data.room_mnc} <> Previous({v_basic_case_rec_data.room_mnc}) then
0
Else
if {v_basic_case_rec_data.surg_descr} <> previous({v_basic_case_rec_data.surg_descr}) then
0

else
IF {v_basic_case_rec_data.room_mnc} = PREVIOUS ({v_basic_case_rec_data.room_mnc})
THEN ({@start} - PREVIOUS ({@end}))/60;



and I'm using this one to exclude times > 120 mins


WhilePrintingRecords;
Global NumberVar TotalHours;
Global NumberVar WorkOrderCount;
Local NumberVar currentdiff;

if {@time diff} > 120 then
currentdiff := 0
else
currentdiff := {@time diff};

TotalHours := TotalHours + currentdiff;
WorkOrderCount := WorkOrderCount + 1;
currentdiff
 
Can you post the whole formula you're using to calculate TotalHours, WorkOrderCount, and the average?

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
this is the formula that I'm using to get the average. Is there something wrong with this? It is giving me the correct average. I have been running each doctor individually (separate reports) but now I need to group them together on same report.


WhilePrintingRecords;
Global NumberVar TotalHours;
Global NumberVar WorkOrderCount;
TotalHours / WorkOrderCount
 
But TotalHours and WorkOrderCount in this formula do not have any values. I suspect that there is another formula or a pair of formulas that set the values for those variables. That's what I want to see.

Thanks!

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
the only other formula I have with variables is the formula below.


WhilePrintingRecords;
Global NumberVar TotalHours;
Global NumberVar WorkOrderCount;
Local NumberVar currentdiff;

if {@time diff} > 60 or {@time diff} = 0 then
currentdiff := 0
else
(
currentdiff := {@time diff};
TotalHours := TotalHours + currentdiff;
WorkOrderCount := WorkOrderCount + 1
);
currentdiff
 
That's what I needed - What you'll do is use the whole "If...Then...Else" statement for the section of the new formula that you're asking about. So, your final formula should look something like this:

Code:
WhilePrintingRecords;
NumberVar DrHours;
NumberVar DrCases;
Local Numbervar currentdiff;

If OnFirstRecord or {table.dr_id} <> previous({table.dr_id}) then
(
  DrHours := 0;
  DrCases := 0;
)
if {@time diff} > 60 or {@time diff} = 0 then 
currentdiff := 0
 else
 (
 currentdiff := {@time diff};
 DrHours := DrHours + currentdiff;
 DrCases := DrCases + 1
 );
if DrCases > 0 then
  DrCases/DrHours;
else 0

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Hi Dell,

I placed the formula on the report in the group footer however it did not return the corrrect data. What am I doing wrong?


WhilePrintingRecords;
NumberVar DrHours;
NumberVar DrCases;
Local Numbervar currentdiff;

If OnFirstRecord or({v_basic_case_rec_data.surg_descr}) <> previous( ({v_basic_case_rec_data.surg_descr})) then
(
DrHours := 0;
DrCases := 0;
)
else
if {@time diff} > 60 or {@time diff} = 0 then
currentdiff := 0
else
(
currentdiff := {@time diff};
DrHours := DrHours + currentdiff;
DrCases := DrCases + 1
);
if DrCases > 0 then
DrCases/DrHours
else 0
 
You didn't use the same logic as I did - there are two separate IF statements - one that initializes the variables to 0 when the group changes and the other that actually calculates the numbers. So, change your formula to this:

If OnFirstRecord or({v_basic_case_rec_data.surg_descr}) <> previous( ({v_basic_case_rec_data.surg_descr})) then
(
DrHours := 0;
DrCases := 0
);
[highlight #FCE94F]//DELETE the "else" that was here and change semi-colons above[/highlight]
if {@time diff} > 60 or {@time diff} = 0 then
currentdiff := 0
else
(
currentdiff := {@time diff};
DrHours := DrHours + currentdiff;
DrCases := DrCases + 1
);
if DrCases > 0 then
DrCases/DrHours
else 0

-Dell

DecisionFirst Technologies - Six-time SAP BusinessObjects Solution Partner of the Year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top