Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsNull and Not Null

Status
Not open for further replies.

records333

Technical User
Mar 16, 2012
41
US
I would like to capture hospital admission type that are null AND capture values that are inpatient and emergency. I tried the following which adversely impacts all records. Any recommendations on the following code?

({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C} in ["1", "2"]and
isnull ({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C}))
 
I have tried something similar to this with my reporting:

IF ISNULL ({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C}) THEN TRUE ELSE
IF ({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C})= "1" THEN TRUE ELSE
IF ({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C})= "2" THEN TRUE ELSE FALSE

Then I would use the select expert to filter out "True"

Maybe this will help you.

 
Yes, and the "OR" condition increased runtime. However, I decided to create a condition;

CONDITION

if isnull({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C})

then "No Data"

else

{ZC_HOSP_ADMSN_TYPE.NAME}

SELECTION CRITERIA

{@hsp admsn type} <> "Elective Admission"


 
Tata004,

I am thinking it is a quirk of Crystal Reports that is getting you. IsNulls have to appear before your other critiera - not sure why that is, but has been my experience, and nearly certain you would find similar responses on TT if you took a look.

Try changing the order of your selection criteria (I assume was what you provided).

Code:
[blue]IsNull[/blue]({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C}) [blue]AND[/blue]
{PAT_ENC_HSP.HOSP_ADMSN_TYPE_C} [blue]in[/blue] ["1", "2"]
note: you do not need the extra parathesis. [smile]

Hope this helps! Cheers!


Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
I think fisheromacse was right when he said it needed to be "OR" rather than "AND". The field can't be null and populated at the same time. As pointed out by MCuthill, you also need to put the IsNull test first.

Try this:

Code:
IsNull({PAT_ENC_HSP.HOSP_ADMSN_TYPE_C}) OR
{PAT_ENC_HSP.HOSP_ADMSN_TYPE_C} in ["1", "2"]

Cheers
Pete
 
To clarify the position with nulls, any Crystal formula will stop if it hits a null, unless an IsNull is applied.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Hahaha. Thanks Pete!

I was looking at this thread for replies this morning, and thought "wait... that should be an OR" (I should really pay attention for same-named fields), scrolled down, and saw you already covered me.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top