Link to home
Start Free TrialLog in
Avatar of HiranB
HiranBFlag for Australia

asked on

How do I calculate the total of a formula?

Hi,

I have created a formula, OBD (Occupied Bed Days) and am trying to get the total by month.

Here are the relevant fields:

Patient Record Number
ICU Admission DateTime
ICU Discharge DateTime

I have two groups:
First is @Month = Month of Discharge as a first grouping.
Second is Patient Record Number

I have also had to look at the Minimum Admission Date = Minimum(ICU_IN_DATE, Patient Record Number) and the Maximum Discharge Date = Maximum(ICU_OUT_DATE, Patient Record Number)  to get a true indication of the patient length of stay. In other words, the number of days the patient occupied a bed. So the formula for OBD is (DateDiff ('h',  {@Minimum Admission Date},{@Maximum Discharge Date} ))/24

My report looks like this:

Group1: @Month
Group2: Patient Record Number
@Minimum Admission DateTime, @Maximum Discharge DateTime, @OBD

The @OBD function works correctly to determine the difference in hours between Max Disch and Min Adm.

My question is, how to I calculate the total @OBD for each month?

I have tried Sum(@OBD,@Month) and it tells me that the @OBD field can't be summarised? The @OBD formula is in my report.
ASKER CERTIFIED SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HiranB

ASKER

Hi Frodoman,

Thanks for the reply but I still have a few questions:

I've created the new formula in the report header - shared numberVar MySubTotal :=0;

My question is on the Accumulated total. My report is grouped by month and I would like a monthly total for the OBD.  "shared numberVar MySubTotal := shared numberVar MySubTotal + [Value Calculated];"
works well to calculate the running total but I would like to be able to display the Total OBD in the group header for @ Month.

I have tried shared numberVar MySubTotal; and it doesn't give me the monthly total. It seems to be showing a running total as well?

Hiran
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is as mlmcc said.  You aren't going to be able to put it in the group header but you should be able to move everything from the header into the footer if you'd like.

The variable will give you a cummulative total until you reset it.  So, if you want to reset it for every group I would say display the result in the group footer, and set the variable to zero in the group header so every group starts over at zero.  If you still need a grand total you'll need to create a separate variable and do the same process, just don't reset to zero in the group header.