Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Create a 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: Create a Formula
     Posted: 27 Jul 2012 at 4:01am
I am pulling info from a SQL database, the field is 99946x10x128:String[5], there are 7 possible values with this field numbering 1 through 7. How do I create a formula that states if field 128 = 1, then it should read "Patient Declined", 2 = Physically Unable... and so on through 7.

I have been trying for days to come up with something... help please!
IP IP Logged
HSD89
Newbie
Newbie
Avatar

Joined: 27 Jul 2012
Online Status: Offline
Posts: 13
Quote HSD89 Replybullet Posted: 27 Jul 2012 at 5:44am
Hi Michele
 
I think i know what your trying to get at and ill give it a shot:-
 
Create a new formula and call it what you will
type the statement as the following
 
if {Table.Field}= 1 then "Patient Declined" else
if {Table.Field}= 2 then "Physically Unable" else
 
and so on untill your finished. Drag that field from the forumla section into the report "Details" section and preview it, should come up with the info you require
 


Edited by HSD89 - 27 Jul 2012 at 5:45am
IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 27 Jul 2012 at 6:07am
when I do that, the formula checker says that the "1" in if {table.field} = 1, it says that a string is required here.


if {lime_survey_99946.99946X10X128} = 1 then "Patient Declined" else
if {lime_survey_99946.99946X10X128} = 2 then "Communication Barrier" else
if {lime_survey_99946.99946X10X128} = 3 then "No Show" else
if {lime_survey_99946.99946X10X128} = 4 then "NA" else
if {lime_survey_99946.99946X10X128} = 5 then "Tablet Not Available" else
if {lime_survey_99946.99946X10X128} = 6 then "Physically too difficult" else
if {lime_survey_99946.99946X10X128} = 7 then "Interferred with Scheduled"
IP IP Logged
HSD89
Newbie
Newbie
Avatar

Joined: 27 Jul 2012
Online Status: Offline
Posts: 13
Quote HSD89 Replybullet Posted: 27 Jul 2012 at 6:16am

replace the "=1" with in [1] and see if that helps

IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 27 Jul 2012 at 6:37am
if {lime_survey_99946.99946X10X128} [1] then "Patient Declined" else
if {lime_survey_99946.99946X10X128} [2] then "Communication Barrier" else
if {lime_survey_99946.99946X10X128} [3] then "No Show" else
if {lime_survey_99946.99946X10X128} [4] then "NA" else
if {lime_survey_99946.99946X10X128} [5] then "Tablet Not Available" else
if {lime_survey_99946.99946X10X128} [6] then "Physically too difficult" else
if {lime_survey_99946.99946X10X128} [7] then "Interfered with Scheduled"

Now it's looking for a Boolean with #7
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 27 Jul 2012 at 11:25am
HSD89 should have said replace "=1"  with ="1" and so forth.  You are checking against a string field, thus you need to compare to a string.  There is also a switch function that should accomplish the same thing as the nested if's.
IP IP Logged
MicheleM
Newbie
Newbie
Avatar

Joined: 05 Apr 2011
Location: United States
Online Status: Offline
Posts: 26
Quote MicheleM Replybullet Posted: 30 Jul 2012 at 4:18am
Thank you so much, that worked. I had to end it with CStr ("Null").
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