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!

Previous Date Sum Question

Status
Not open for further replies.

cabrera01

Technical User
Nov 24, 2008
15
I have a report that I wrote in crystal 10 in which I'm trying to sum of a field that is using the previous formula. I need to be able to calculate the number of days it took for a patient to be re-admitted a hospital. Each patient is grouped by their account number.

I have a current discharge date formula as:
(@testadm):
whileprintingrecords;
datevar testdisch:={@admitn}

the previous discharge date formula is:
(@prevdisch):
whileprintingrecords;
datevar prevdisch:=PREVIOUS({@dischn})

(@admitn) = cdate(totext({BADPLPP.LPADT1},"00")+"/"+
totext({BADPLPP.LPADT2},"00")+"/"+
totext(2000+{BADPLPP.LPADT3},"0000"))

(@dischn) = cdate(totext({BSYRRVU.RVLDD1},"00")+"/"+
totext({BSYRRVU.RVLDD2},"00")+"/"+
totext(2000+{BSYRRVU.RVLDD3},"0000"))

I can get the number of days between days by using the formula (@redays):
if {@testADM}-{@prevDISCH}<0 then 0 else {@testADM}-{@prevDISCH}


The problem I have is if I'm trying to sum the totals.

Do you have any suggestions what I can do to resolve this summation problem.

Thank you
 
You will have to do a manual running total using variables, you can google the topic if you want more info about why, etc, but it will be something like:

(Reset may not be necessary unless you actually do need to reset it, put it in the section of your report where/if you want to reset)
Code:
@Reset
whileprintingrecords;
global numbervar RT:=0;
(put it in the section you want total to increment, likely same section @redays resides, you will probably need to suppress it after you ensure it works)
Code:
@Increment
whileprintingrecords;
global numbervar RT:= RT+@redays;
(put it in the section you want to display the running total, it will display the last value held of increment above, this is likely the trickiest one to place and you may need to play around with it)
Code:
@Display
whileprintingrecords;
global numbervar RT;
 
This helps to get the correct days, but I want to be able to use this formula called (@less7):

if isnull({@prevDisch}) then 0 else if {@Sum}<= 7 then 1.

After this formula, I would like to be able to use either the sum or running total function, but I can't select sum on this field.

The forumla (@Sum) is the increment formula.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top