Author |
Message |
freakingeek
Newbie
Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
|
Topic: if -then statement not showing in report. Posted: 27 Feb 2014 at 10:31am |
Hello,
I have what seems like a simple issue. Yet, I cannot get my formula to show in the report. The header for this particular column is Gender. By default the report shows numbers representing the following - Male, Female, other or unknown. I want the report to reflect the names that the numbers represent. Here is my formula: if {DDB_PAT_BASE.Gender}=1 then "Male" else if {DDB_PAT_BASE.Gender}=2 then "Female" else if {DDB_PAT_BASE.Gender}=3 then "Other" else if {DDB_PAT_BASE.Gender}=4 then "Unknown"
I don't get any errors, but the values don't change, they still show only the numbers in the report.
What am I doing wrong?
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 27 Feb 2014 at 10:56am |
Did you replace the {DDB_PAT_BASE.Gender} in the column with the formula?
|
IP Logged |
|
hello
Groupie
Joined: 05 Feb 2014
Online Status: Offline
Posts: 85
|
Posted: 27 Feb 2014 at 11:02am |
Is the table field numeric or string?
If it's numeric, add this to the top:
stringvar gender_string;
In the formula add:
gender_string = "male" instead of just "male". Same for "female", "other", "unknown"
Then at the bottom:
gender_string
Edited by hello - 27 Feb 2014 at 11:08am
|
IP Logged |
|
hello
Groupie
Joined: 05 Feb 2014
Online Status: Offline
Posts: 85
|
Posted: 27 Feb 2014 at 11:12am |
Or, maybe you just need the little := thingy instead of =
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 27 Feb 2014 at 1:04pm |
The formula is not assigning a value, thus the := is not necessary. I am still guessing that freekingeek just did not drop the formula on the sheet, still looking at the field.
|
IP Logged |
|
freakingeek
Newbie
Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
|
Posted: 28 Feb 2014 at 3:21am |
I tried using the "stringvar gender_string;" but then it looks for a string value. The value in the table is numeric. If I look at the present output in the report, I have numbers 1-4 representing the sex of the patient. I want the sex to show as male, female, other or unknown.
The formula I used is from another report using the same table. I just changed the report name to match mine. It works in the other report.
So how do I get the report to reflect what I want as far as Gender goes?
|
IP Logged |
|
adavis
Senior Member
Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
|
Posted: 28 Feb 2014 at 4:10am |
You said you just renamed an existing report? So you haven't changed any of the report fields?
I think kevlray may be correct about the wrong field being in the report. Can you try just removing the field from the report and placing the formula field in its place?
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 28 Feb 2014 at 5:00am |
as always, one simple way to debug a formula is to break it into pieces. in this case just showing the field...which will satisfy adavis and kevlray suspicions.
Since CR is a black box, the best we can do is make sure that what we think is happening actually is.
|
IP Logged |
|
hello
Groupie
Joined: 05 Feb 2014
Online Status: Offline
Posts: 85
|
Posted: 28 Feb 2014 at 5:56am |
stringvar gender_string;
if {DDB_PAT_BASE.Gender}=1 then gender_string := "Male"
else if {DDB_PAT_BASE.Gender}=2 then gender_string := "Female"
else if {DDB_PAT_BASE.Gender}=3 then gender_string := "Other"
else if {DDB_PAT_BASE.Gender}=4 then gender_string := "Unknown";
gender_string
PS:
I've never really been sure when to use the = or the :=
so I try it both ways.
Edited by hello - 28 Feb 2014 at 6:00am
|
IP Logged |
|
freakingeek
Newbie
Joined: 27 Feb 2014
Location: United States
Online Status: Offline
Posts: 7
|
Posted: 28 Feb 2014 at 5:59am |
So are you asking to see the field as it reflects in the report? In the formula I am using the same table that exists in the database.
And the field I have in the report is the same as whats in the formula.
The formula I copied from the other report, is using the same table.
|
IP Logged |
|
|