Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: count specific records formula Post Reply Post New Topic
Author Message
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Topic: count specific records formula
     Posted: 27 Mar 2013 at 11:20am
Hello
 
I need to do a distinct count of patientID's if a field value contains the word "methadone"
 
Im thinking i should do a running total
-Field to summarize select the field PATID
-Type of Summary select distinct count
-Evaluate i should use a formula but I can recall what is the proper way to write the formula if i only want to count records that have the word "methadone" in them
-and Reset Never
 
Help!
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 28 Mar 2013 at 1:43am
I think you could do it without a running total as well. Create a formula like below:

formulaname: PatientID
if {table.field} <> "methadone" then PatientID else "FALSE"

then create another formula to actually count the PatientID's. Only thing is, that it will also count the value FALSE. So you have to count it, minus 1

distinctcount({PatientID}) - 1.

If you want to use a running total, I think the formula should be something like

{table.field} <> "methadone"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Mar 2013 at 3:49am
To clarify, if the field can have more than just methadone in the string you might want to use a LIKE function
RT version would be
field to sumamrize=patid
type = distinctcount (assuming you do not want account of occurances)
evaluate=use a formula
{table.field} like '*methadone*'
reset= never for a report total
place in the detail or footer section. RT's do not work in headers


Edited by DBlank - 28 Mar 2013 at 3:50am
IP IP Logged
sanchezgmc06
Senior Member
Senior Member
Avatar

Joined: 21 Jan 2011
Online Status: Offline
Posts: 107
Quote sanchezgmc06 Replybullet Posted: 28 Mar 2013 at 7:07am
DBlank
 
This worked perfect!
 
Thank you
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