Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Need help with trying to use formuls in section ex Post Reply Post New Topic
Author Message
saumyarpandey
Newbie
Newbie


Joined: 04 Dec 2012
Online Status: Offline
Posts: 11
Quote saumyarpandey Replybullet Topic: Need help with trying to use formuls in section ex
     Posted: 29 Apr 2013 at 8:37am
Hi All,

I am trying to use a formula to select only patients that have diabetes. After that if they have HGBA1C/HGBA1C%POC values then I want those values displayed else if its null value then just a blank space. But I want all patients with diabetes displayed. Somehow my formula is not working the way I want it to (its written below, the part I wrote is in bold). PLEASE PLEASE PLEASE help!!

{PERSON.PSTATUS} = "A" and
{PROBLEM.CODE} in ["1ICD-250.1", "ICD-250", "ICD-250.0", "ICD-250.00", "ICD-250.01", "ICD-250.02", "ICD-250.03", "ICD-250.10", "ICD-250.11", "ICD-250.12", "ICD-250.13", "ICD-250.2", "ICD-250.20", "ICD-250.21", "ICD-250.22", "ICD-250.23", "ICD-250.3", "ICD-250.30", "ICD-250.31", "ICD-250.32", "ICD-250.33", "ICD-250.4", "ICD-250.40", "ICD-250.41", "ICD-250.42", "ICD-250.43", "ICD-250.5", "ICD-250.50", "ICD-250.51", "ICD-250.52", "ICD-250.53", "ICD-250.6", "ICD-250.60", "ICD-250.61", "ICD-250.62", "ICD-250.63", "ICD-250.7", "ICD-250.70", "ICD-250.71", "ICD-250.72", "ICD-250.73", "ICD-250.8", "ICD-250.80", "ICD-250.81", "ICD-250.82", "ICD-250.83", "ICD-250.9", "ICD-250.90", "ICD-250.91", "ICD-250.92", "ICD-250.93"] and
not ({PERSON.SEARCHNAME} startswith "<MRG>") and
If ({OBSHEAD.NAME} like ["*HGBA1C", "*HGBA1C%POC"]) then ["*HGBA1C", "*HGBA1C%POC"]else if isnull {OBSHEAD.NAME} then " "

Edited by saumyarpandey - 29 Apr 2013 at 9:15am
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 29 Apr 2013 at 10:06pm
what is the formula doing? You could try changing it to

If ({OBSHEAD.NAME} like ["*HGBA1C", "*HGBA1C%POC"]) then {OBSHEAD.NAME} else if isnull {OBSHEAD.NAME} then " "
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 30 Apr 2013 at 12:09am
Hi

Little modifications to Gurbs formula :


If (Trim({OBSHEAD.NAME}) like ["*HGBA1C", "*HGBA1C%POC"]) then {OBSHEAD.NAME} else
if (isnull({OBSHEAD.NAME}) or {OBSHEAD.NAME} =" ") Then " "

Thanks,
Sastry
IP IP Logged
saumyarpandey
Newbie
Newbie


Joined: 04 Dec 2012
Online Status: Offline
Posts: 11
Quote saumyarpandey Replybullet Posted: 30 Apr 2013 at 4:52am
Hi Sastry and Gurbs,

Thanks for the help, I am still getting an error message saying 'a Boolean is required here'. It should not be the case as there is an and operator besides I have tried many different ways to do it but the trouble is still there. Please tell me what I might be doing wrong??

Thanks,

Saumya
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 30 Apr 2013 at 11:22pm
Where is he saying 'a Boolean is required here', which part of the formula is being highlighted?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 01 May 2013 at 5:38am
Also, you need to do the check for IsNull BEFORE doing the check for a value.  You can see my blog post here http://sapbiblog.com/2013/03/25/what-is-null-and-why-is-it-important-for-crystal-reports/ for more information about why it needs to be done this way.
 
-Dell
IP IP Logged
saumyarpandey
Newbie
Newbie


Joined: 04 Dec 2012
Online Status: Offline
Posts: 11
Quote saumyarpandey Replybullet Posted: 01 May 2013 at 7:08am
The code that I have written :-( is the part for which I am getting the error message. It is highlighted already. As for me choosing the null value later is because the table stores data for mammogram, pap, hgba1c etc etc but I need to find only the null values for patients who's A1c value is null. I tried writing the code as suggested
"
if (isnull({OBSHEAD.NAME}) or {OBSHEAD.NAME} =" ") Then " " else
If (Trim({OBSHEAD.NAME}) like ["*HGBA1C", "*HGBA1C%POC"]) then {OBSHEAD.NAME}
"
but still getting the same error message for this part of the code.

:-(

Edited by saumyarpandey - 01 May 2013 at 7:19am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 01 May 2013 at 9:00am
Where are you using this code?  I would expect to see the first part (before the If statement) in the Select Expert to filter out all of the non-diabetes data.  I would then rewrite the formula that displays data to something like this:
 
if (not isnull({OBSHEAD.NAME}) and  InStr({OBSHEAD.NAME}, "HGBA1C" = 0)) Then {OBSHEAD.NAME} else " "
 
In a formula use InStr() to determine whether a string contains another string - "like" doesn't really work in this situation.
 
-Dell
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