Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Trying to use previous in a running total? Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Trying to use previous in a running total?
     Posted: 17 Jul 2013 at 7:30am
Hi

I'm trying to do the following to formula @NoUnits

If IsNull({RECORDED_SERVICE.UNITS}) Then
{SERVICE_STATUS.Code}
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='AM'  then '1AM'
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='PM'  and previous(cdate({RECORDED_SERVICE.STARTTIME})) = cdate({RECORDED_SERVICE.STARTTIME}) then 'AMPM'
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='PM'  and previous(cdate({RECORDED_SERVICE.STARTTIME})) <> cdate({RECORDED_SERVICE.STARTTIME}) then '1PM'
else
ToText({RECORDED_SERVICE.UNITS})


The above errors I think its got to do with previous(cdate) ?

I then want to use @no-units in a running total but getting stopped


Sorry I know its unclear...
I think for now I'd like to compare the date portion of the datetime field(startime) to the previous one, then go from there..

Thanks



IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 17 Jul 2013 at 7:44am
Ok so kind of hacky I did a formula with previous cdate of startime and current...
If IsNull({RECORDED_SERVICE.UNITS}) Then
{SERVICE_STATUS.Code}
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='AM'  then '1AM'
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='PM' and {@previouscdatesd} = {@cdatesd}  then 'AMPM'
else
if {CLINICAL_PLACE_OF_SERVICE.Code}='PM' and {@previouscdatesd} <> {@cdatesd}  then '1PM'
else
ToText({RECORDED_SERVICE.UNITS})


which works but I  am also trying to do a matrix like report so it has a coulum for each day of the month

name....1...2...3....4.... etc

I want to display the @No_Units for each day so I am trying a running total formula for each day

example day1 running total is

get max value of @No_Units
formula =  DatePart ("d",{RECORDED_SERVICE.STARTTIME}) =1
reset on grouping of startime by day

problem is I get the error ....  a running total cannot refer to a printtime formula Details: @NoUnits

I asum I'm getting it from the formula I use to the the previous date..

Any ideas on other ways to do this would be grteat

Thanks



IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Jul 2013 at 7:48am
switch the locations of cdate and previous
cdate(previous({RECORDED_SERVICE.STARTTIME}))
 
 
that wont help with the runtime issue
 
can you post sample data?
Do you have any primary Keys in the data set that can be utilized?


Edited by DBlank - 17 Jul 2013 at 7:51am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 17 Jul 2013 at 8:03am
So if you group on name then startime
and look at the data if looks like

Name            Starttime           code @No_units
Sam Adams  6/1/13 08:00AM AM     1AM
Sam Adams  6/1/13 02:45PM PM     AMPM
Sam Adams  6/2/13 08:00PM AM     1AM
Sam Adams  6/3/13 02:45PM PM     1PM
etc..

so on startime footer

if they have an amand pm code on same day then ampm if only am then 1am if only pm then 1pm

Client                 1      2       3           etc....
Sam Adams     AMPM  1AM  1PM 

make anymore sense?




Edited by jbalbo - 17 Jul 2013 at 8:04am
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 17 Jul 2013 at 10:51am
Dan

I went about this a different way and did a crosstab report instead of 31 running totals and lots of formatting..lol I know dumb!!

I do have a question about the crosstab.. guess I start a new thread..

Thanks for the help

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum