Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Creating a new formula Post Reply Post New Topic
Author Message
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Topic: Creating a new formula
     Posted: 15 Aug 2012 at 3:44am
Working in SQL and am trying to figure out how to do this.

I've had to create "formula's" to change memo fields to strings so that they can be grouped and sorted.

One of these "grouped" fields is sorted by client. In the information contained I have survey type, submit date, and some other things.

I need to create a formula that tells me if each grouped client has both survey types.

In my head the formula goes like this:

If "patient group" contains "survey type 1" and "submit date" and "survey type 2" and "submit date" then true else false

I am new at this and these formula's are either simpler than you think or more complicated.

This is what I tried after other numerous others:

If GroupName ({@Patient}) =
{lime_survey_27974.27974X51X1763}"1" & {lime_survey_27974.submitdate} and
{lime_survey_27974.27974X51X1763}"2" & {lime_survey_27974.submitdate} then "True"

and no, this didn't work. I'm trying.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Aug 2012 at 3:57am
Do you want a crystal solution or a SQL solution?
in SQL you can do a seperate sub queries to handle your processes.
 
In crystal create 2 different formuals to create flags for each condition at the group level
//Flag_1
if {lime_survey_27974.27974X51X1763}="1" then 1
sum it at the patient group level
//Flag_2
if {lime_survey_27974.27974X51X1763}="2" then 1
sum it at the patient group level
now you can do another formula (or group select criteria if you want to limit your data)
if sum(@flag_1,table.patient)>0 and sum(@flag_2,table.patient)>0 then 'True'
IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 23 Aug 2012 at 10:58am
Now for my next question... how do I count my trues? I can't group/subtotal or select that field. I've converted the true false to True =1 else 0, and now it's a number, but I still can't group/subtotal or select just the "Trues"


//Flag_1
if {lime_survey_27974.27974X51X1763}="1" then 1

//Flag_2
if {lime_survey_27974.27974X51X1763}="2" then 1

if sum ({@Flag_1}, {@Patient})>0 and sum ({@Flag_2}, {@Patient})>0 then "True"

if {@True Total}="True" then 1 else 0

What am I not doing right. I've tried running totals, trying to do a parameter... anything I could think of and now I have to ask for help.

I so tried.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2012 at 11:04am
you will be mad when you see how to do it...
create a running total
name=whatever
field to summarize=patient
type=distinctcount
evaluate=use a formula
sum(@flag_1,table.patient)>0 and sum(@flag_2,table.patient)>0
reset=never
place in report footer for grand total
IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 24 Aug 2012 at 3:27am
Shaking my head on that one, I was so close (and yet so far) from that formula in the Running Totals. THANK YOU so much.
IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 24 Aug 2012 at 3:28am
PS... YOU ROCK!
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