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

Summarize Formula Which Uses PREVIOUS Function In Crystal - How?

Status
Not open for further replies.

kitster100

IS-IT--Management
Sep 13, 2013
2
US
I am trying to compare the difference in two date-time fields suing the PREVIOUS function in Crystal. My problem is that Crystal won’t let me summarize my result in any way, whether it’s a Count, Average, or anything else. I get the error: “This field cannot be summarized”.
My two date-time fields are:

-Patient_Datetime_IN_Room.
-Patient _DateTime_Out_of_Room

I am calculating the room turnover (Room T/O), that is, the minutes between when, say, PT (patient) A was wheeled out of surgery, and the NEXT PT was wheeled in to the same room to undergo surgery.
Here’s what my Detail section on my report looks like
PT # PT Room Patient_Datetime_IN_Room Patient_DateTime_Out_of_Room room T/O
1 10 8-5-13 07:15:00 8-5-13 9:00:00 none (1st case of day)
2 10 8-5-13 09:15:00 8-5-13 10:00:00 15


I am trying to average the turnover at a monthly level (across all room), which means I need a fomula to calculate:
Jan T/O Avge: 25 Min
Feb. T/O Avge: 20 min

I also need to group by room at a later time. (i.e., Avge turnover for room 10 for Jan: 15 min, etc)
So, room T/O is PT 2’s time In minus PT 1’s time out of room. (9:15 minus 9:00=15 min)
My formula to for the detail section to calculate room turnover is:

//Formula: @turnover
(if datediff ("n", previous({EpicCases.Pat_DateTime_ OutofRoom}),{EpicCases.Pat_DateTime_InRoom})>=60
or datediff ("n", previous({EpicCases.Pat_DateTime_ OutofRoom}),{EpicCases.Pat_DateTime_InRoom})<0
then tonumber({@fnull})
else
if(time({EpicCases.Pat_DateTime_InRoom})in time(6,30,00) to time(17,00,00))
then
datediff ("n", previous({EpicCases.Pat_DateTime_ OutofRoom}),{EpicCases.Pat_DateTime_InRoom}))

//end formula

First, I am filtering out any turnover time between cases greater than 1 hour. Also, using an empty formula (@fnull), I’m excluding data entry errors where the wrong time was entered which leads to a minus turnover. (Rare, but it happens).
Next, I use the PREVIOUS function to calculate the minutes elapsed between time in to room for the most recent patient vs. time out of the room for the patient immediately before him/her, for the same room.

As I mentioned, when I try to do any summary calculation, I get the error: “This field cannot be summarized”.

At first I thought that perhaps my @turnover formula was not a number datatype. However, it is a number. I even tried creating a new formula called @makeTurnoveraNumber, and used the tonumber convert function on my @turnover formula, like this:
//formula: @ makeTurnoveraNumber
Tonumber({@turnover})

It did not work. Evidently, using the PREVIOUS function eliminates any possibility of summarizing anything in which it’s used, is that right?

I’m running Crystal Reports 10.0.0.53 (Crystal 10).

If so, what can I do to summarize the @turnover at both the group, and report level?
Any help would be appreciated. Thank you in advance.
 
At detail level, try a formula field @timeinroom
where it clears up all the instances of bad data here first at line level, using IF and case statements etc.
You should then be able to refer to this new field and use PREVIOUS in a 2nd formula field or use running total functions on the new formula field.
 
Nickie:
What worked was setting a variable in the details, and keeping count in both the group and report level. This meant:
1. A formula in the report header setting the variable to zero.
2. Incrementing it in the detail area
3. Summing it up in both the group and report footers.

True, using the Running Totals feature may have worked as well. I just ran out of time.

Thanks for responding!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top