I Are Dumb
Nov. 13th, 2008 04:53 pmOr maybe it's Crystal Reports, not me.
I run into this problem now and again, where I need to do a report on a database field that might or might not have actual data in it.
As an example, starting with a report that shows the value of Funfield in all records:
Name Funfield
Boo Foo
Goo Ooo
Joo Due
Noo
Now I modify this report to show all records where Funfield = Foo.
Name Funfield
Boo Foo
Next, show all records where Funfield != Foo.
Name Funfield
Goo Ooo
Joo Due
Why isn't Noo on this report?
If I try isnull({funfield}), I get no results:
Name Funfield
Now, say I do a formula named "NoFun" and define it as "if {funfield} = Foo then true, else false" and display it on my original all-results report, I get:
Name Funfield Nofun
Boo Foo True
Goo Ooo False
Joo Due False
Noo False
But if I try to get sneaky and ask for all results where Nofun is False:
Name Funfield Nofun
Goo Ooo False
Joo Due False
... Noo's still missing.
Anyone out there smarter than me that knows (a) why this happens and/or (b) how I can get around this? I'm using Crystal v.11.
... and preferably short of redoing the report in Excel, because it's not this simple a report. ;_;
I run into this problem now and again, where I need to do a report on a database field that might or might not have actual data in it.
As an example, starting with a report that shows the value of Funfield in all records:
Name Funfield
Boo Foo
Goo Ooo
Joo Due
Noo
Now I modify this report to show all records where Funfield = Foo.
Name Funfield
Boo Foo
Next, show all records where Funfield != Foo.
Name Funfield
Goo Ooo
Joo Due
Why isn't Noo on this report?
If I try isnull({funfield}), I get no results:
Name Funfield
Now, say I do a formula named "NoFun" and define it as "if {funfield} = Foo then true, else false" and display it on my original all-results report, I get:
Name Funfield Nofun
Boo Foo True
Goo Ooo False
Joo Due False
Noo False
But if I try to get sneaky and ask for all results where Nofun is False:
Name Funfield Nofun
Goo Ooo False
Joo Due False
... Noo's still missing.
Anyone out there smarter than me that knows (a) why this happens and/or (b) how I can get around this? I'm using Crystal v.11.
... and preferably short of redoing the report in Excel, because it's not this simple a report. ;_;
no subject
Date: 2008-11-13 11:50 pm (UTC)no subject
Date: 2008-11-13 11:54 pm (UTC)I Are Not Reel Programr
Date: 2008-11-14 12:24 am (UTC)But with this numeric field, if I look at the null fields in the actual database, they display as blank, not zero. However, in Crystal's report they show as 0:
Name Funfield
Boo 10
Goo 2
Joo 5
Noo 0
Funfield = 2 would get me:
Name Funfield
Goo 2
But Funfield = 0 just gives:
Name Funfield
No results. >.
It might work!
Date: 2008-11-14 12:28 am (UTC){funfield} not in [70,80,90]
I'm not sure offand if Crystal has another construction for "not" but I'll take a look when I'm at work tomorrow. Can't hurt.
Re: I Are Not Reel Programr
Date: 2008-11-14 12:35 am (UTC)Re: I Are Not Reel Programr
Date: 2008-11-14 12:40 am (UTC)Crystal also has a toggle for "force NULL values to 0", I think. I can try playing with that and isnull and =0 in various configurations, and see if I get anything.
no subject
Date: 2008-11-14 02:04 am (UTC)no subject
Date: 2008-11-14 03:56 am (UTC)no subject
Date: 2008-11-14 04:25 am (UTC)Select ... From ...
Where (Funfield is NULL) or (FunField not in (70, 80, 90))
and Crystal is mangling the interpretation of that expression.
I've never used Crystal Reports, but if there's a way to see what SQL it is generating to retrieve the data, you can better understand the nature of the bug.
IEEE single precision programmer
Date: 2008-11-14 01:46 pm (UTC)for the case of Oracle behind Crystal:
nvl(Foo,0) will substitute 0 for Foo if Foo is null
MS SQL Server uses isnull(Foo,0) in the same fashion.
Oracle will treat a zero length string as null.
Hopefully those three items will help! Feel free to direct mail further questions, I'm looking at it from a DB engine perspective rather than the reporting tool obviously...
no subject
Date: 2008-11-14 02:08 pm (UTC)Try the CR forums at tekteps.com!
Hope that helps!
Re: I Are Not Reel Programr
Date: 2008-11-14 02:09 pm (UTC)