|
-
Sep 25th, 2006, 05:20 AM
#1
Thread Starter
Lively Member
[RESOLVED] [2005] Exclude nulls in Crystal Record Selection Formula
Hi
Can anyone tell me how I exclude any records with a null value in a certain column when building a Record Selection Formula?
Thanks.
-
Sep 25th, 2006, 05:28 AM
#2
Fanatic Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
I'm not sure with this but still try:
[Field] <> Null
or
NOT [Field] = Null
-
Sep 25th, 2006, 05:36 AM
#3
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
I tried "and not (IsNull ({reportView_CompletedAll.Decision}))", this comes up with no errors but doesn't bring back the results I'm expecting!
-
Sep 25th, 2006, 05:50 AM
#4
Fanatic Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
This work fine:
not isnull({[table].[field]})
I see that there is an "AND" in your statement, what is the other criteria?
-
Sep 25th, 2006, 05:53 AM
#5
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
Year ({reportView_CompletedAll.DateAwarded}) in {?Academic Year} to ({?Academic Year} + 1)
and
if Year ({reportView_CompletedAll.DateAwarded}) = {?Academic Year}
and Month ({reportView_CompletedAll.DateAwarded}) > 8 then True else False
or
if Year ({reportView_CompletedAll.DateAwarded}) <> {?Academic Year}
and Month ({reportView_CompletedAll.DateAwarded}) < 9 then True else False
and not(IsNull ({reportView_CompletedAll.Decision}))
-
Sep 25th, 2006, 10:05 AM
#6
Re: [2005] Exclude nulls in Crystal Record Selection Formula
It looks like you are selecting records for an entire year (from Aug, 1 to Aug 31)
{reportView_CompletedAll.DateAwarded} in DateSerial({?Academic Year}, 8, 1) to DateSerial({?Academic Year} + 1, 9 ,1) And
Not IsNull ({reportView_CompletedAll.Decision})
Crystal seems to have problems generating the SQL statement properly when using IsNull. Anyways, try the above and if it still does not work post the Where clause of the SQL Statement that is generated by Crystal (Database -> Show SQL Query menu).
-
Sep 25th, 2006, 10:28 AM
#7
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
It's still bringing back records that have a null value in the {reportView_CompletedAll.Decision} field.
Here's the SQL it generates:
SELECT "reportView_CompletedAll"."DateAwarded", "reportView_CompletedAll"."fore", "reportView_CompletedAll"."Sur", "reportView_CompletedAll"."Mode", "reportView_CompletedAll"."RegistrationDate", "reportView_CompletedAll"."Name", "reportView_CompletedAll"."Decision", "reportView_CompletedAll"."CompDate", "reportView_CompletedAll"."ECName"
FROM "ResearchDB"."dbo"."reportView_CompletedAll" "reportView_CompletedAll"
ORDER BY "reportView_CompletedAll"."Name", "reportView_CompletedAll"."Mode"
-
Sep 25th, 2006, 12:10 PM
#8
Re: [2005] Exclude nulls in Crystal Record Selection Formula
In Report Options, are the following Checked or UnChecked.
Convert Null Field Value to Default
Use Indexes or Server for Speed
-
Sep 26th, 2006, 02:36 AM
#9
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
The "Convert Database NULL Values to Default" and "Convert Other NULL Values to Default" options were not checked but the "Use Indexes or Server for Speed" was checked.
I've tried checking and unchecking them in various combinations but it doesn't make any difference.
-
Sep 26th, 2006, 03:30 AM
#10
-
Sep 26th, 2006, 10:14 AM
#11
Re: [2005] Exclude nulls in Crystal Record Selection Formula
The Formula I posted is fine, at least it works in Crystal 8.5 against the Northwind.Orders table (SQL Server).
Does the date portion of the formula work for you?
What I find curious is that there is no Where clause being generated by Crystal.
-
Sep 26th, 2006, 10:19 AM
#12
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
Yeah, I thought that was weird too!
The dateserial formula works fine, it's just the part where I want to exclude any records that have NULL in the {reportView_CompletedAll.Decision} field. Even with the Not IsNull ({reportView_CompletedAll.Decision}) line (and variations thereof!) it still brings back these rows!
-
Sep 26th, 2006, 11:37 AM
#13
Re: [2005] Exclude nulls in Crystal Record Selection Formula
Perhaps the Decision field isn't equal Null but "". To check add the following formula and place it on the report.
Code:
If IsNull({reportView_CompletedAll.Decision}) Then
"Null"
Else
If {reportView_CompletedAll.Decision} = "" Then
"Empty String"
Else
{reportView_CompletedAll.Decision}
-
Sep 27th, 2006, 04:37 AM
#14
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
I put a slightly altered version of your code in (it brought up errors without the alteration) but doesn't give any different results, it's like it's not even looking at that field.... the altered version is below:
If IsNull({reportView_CompletedAll.Decision}) Then
{reportView_CompletedAll.Decision} = "Null"
Else
If {reportView_CompletedAll.Decision} = "" Then
{reportView_CompletedAll.Decision} = "Empty String"
Else
{reportView_CompletedAll.Decision} = {reportView_CompletedAll.Decision}
-
Sep 27th, 2006, 10:25 AM
#15
Re: [2005] Exclude nulls in Crystal Record Selection Formula
No. I meant create a new Formula. The code I posted does not belong in the Record Selection Formula.
Print/show this new formula somewhere on the report, preferrably the details section and let me know what gets printed for a row that is null.
-
Sep 27th, 2006, 10:39 AM
#16
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
Ah! I see what you mean! Sorry!
I created a formula called nullField and put in on the report, the fields that i thought were null were in fact empty strings as you suggested. Then I added the following code to my record selection formula but it made no difference, can you see what I'm doing wrong? Thanks for all your help!
select {@nullField}
case "Null": False
case "EmptyString": False
default: True
-
Sep 27th, 2006, 11:37 AM
#17
Re: [2005] Exclude nulls in Crystal Record Selection Formula
The new formula was just to help in debugging the problem. There is no reason to use it in the Record Selection formula.
Since the Decision field is an empty string the following should work
{reportView_CompletedAll.DateAwarded} in DateSerial({?Academic Year}, 8, 1) to DateSerial({?Academic Year} + 1, 9 ,1) And
{reportView_CompletedAll.Decision} <> ""
-
Sep 28th, 2006, 02:57 AM
#18
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
Thanks, I've just tried that now but it makes no difference whatsoever! I looked at the SQL being generated by Crystal and there is still no where clause being included! I'm baffled!
This is my first time using Crystal, I had no idea it would be so difficult and uninituitive! Give me a programming language anyday!!! Is that your experience of it too?
-
Sep 28th, 2006, 05:19 AM
#19
Thread Starter
Lively Member
Re: [2005] Exclude nulls in Crystal Record Selection Formula
OK, I surrender! I've changed the way I get the data. I'm now using a view which contains a where clause to exclude the null, I can't see any other way to do it! Thanks so much for your help Brucevde!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|