Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Help Post Reply Post New Topic
Author Message
gcross
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 2
Quote gcross Replybullet Topic: Formula Help
     Posted: 04 Mar 2010 at 1:51pm
I am new to using Crystal Reports and could use some advice. I am trying to write a report that will do a few things. The first is to give me a total of patients that a Dr. has seen and I have completed that. The second is to break out the total number of diagnosis that were Medical ( there are 80 or so), Routine ( only 3 or 4) and Test( 20 or so) codes. I have started with a simple script (which is below) to make sure I am getting the syntax correct. I put this on each line of the detail section and I am recieving a "True" for the rows that meet the "else statement" and a "False" for the rows that meet the "then statement". I was wanting this to return a 1, is this possible? I then would like to put this into a while or until loop to run through all of the records and I can put the total in the footer. Is this possible and if so can someone get me started with an example? Thank you in advance.
 
 
whileprintingrecords;
numberVar i:=0;
If {LEDGER.CODE} = '92004' then i=i+1
else i=i+0;
 
Thanks,
Ray
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Mar 2010 at 7:10am
To assign a varible a value you need to use ':=' not '=' otherwise it will evaluate to true or false (done this myself way too many time).
IP IP Logged
gcross
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 2
Quote gcross Replybullet Posted: 05 Mar 2010 at 7:16am
Thank you that is very good to know.
 
Could anyone give me an example on how to loop through the records to return the count of each type of Diagnosis code?
 
Thanks,
Ray
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Mar 2010 at 7:40am
I think you may be overcomplicating your process.
You can create a Running Total (or a variable formula) to count per row. Not knowing your data it is hard to say but your original description leads me to believe a RT would be fine.
I assume you have agroup on the doctor field.
Create a RT as "RoutineCount"
Field to Summarize=PK field per Visit or PK field for each patient depending on what you want to count (patients or visits)
Summary Type=DistinctCount
Evaluate = Use a formula...make a formula to look at the diagnosis that is a 'Rountine' Diag, likely something like this....
{LEDGER.CODE} in ['code1','code2','code3',etc.]
Reset=On change of group (select doctor group)
place on Group footer (RTs do not work in headers) for the Doctor level group.
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