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!

Reset formula to zero on change of group

Status
Not open for further replies.

jenschmidt

Programmer
Sep 30, 2002
145
US
Good Morning!

I want to know the length of time that passes between visits for each patient (the report is grouped by patient). I need the formula that calculates the length of time to reset every time there is a new patient group. The formula is:

{TABLE.VISIT_DATE} - Previous({TABLE.VISIT_DATE})

Any ideas?
Thanks a bunch!
jennifer.giemza@uwmf.wisc.edu
 
Have you tried use a running total formula that resets on each patient?
 
A running total field is the way to go , not a formula field.

From the insert menu select field object, running total field, select the field to accumulate (or the formula field to accumulate), set evaluation to every record, and reset the runnning total on change of group = patient.

Let me know if you have any questions. Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
I tried the running total but it won't perform the function necessary to see, within the set of visits for each patient, the length of time from one to the next. I tried to add the formula field into the running total, but it doesn't appear in the pick list.

jennifer.giemza@uwmf.wisc.edu
 
Please post the formula you tried to use in your running total field. Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
a couple of questions:

Are you looking for the difference in time between each two visits or are you looking for the difference between the first visit and the last visit? (assuming we can have 3 or more visits)

for example:

Patient Visit Date Lapsed time(days)
JDoe 01/01/02
01/17/02 16
01/24/02 7
or is it

Patient Visit Date Lapsed time(days)
JDoe 01/01/02
01/17/02
01/24/02 23

You should define your problem a bit better. You can use DateDiff() to determine the time difference in whatever format you want (days, months or even time too).

If it is the second senario then all you have to do is grab the first and last visiting date and preform the DateDiff. You could initialize your first date to the first date encountered in the Patient Group Header.
@Intialization
WhilePrintingRecords;
datevar firstdate := {TABLE.VISIT_DATE};

In the Patient Group Footer compute the difference between the first date and last date

@Elapsed time
WhilePrintingRecords;
datevar firstdate;
DateDiff("d",firstdate, {TABLE.VISIT_DATE});
(I may have the syntax wrong but you get the idea)

If there has only been one date then this will evaluate to zero.

Hope this helps
Jim


Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top