I Are Dumb

Nov. 13th, 2008 04:53 pm
rowyn: (downcast)
[personal profile] rowyn
Or 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. ;_;

Date: 2008-11-13 11:50 pm (UTC)
From: [identity profile] sebkha.livejournal.com
Crazy thought: try not(Funfield = Foo).

Date: 2008-11-13 11:54 pm (UTC)
From: [identity profile] terrycloth.livejournal.com
Can you specifically include blanks somehow maybe?

Re: I Are Not Reel Programr

Date: 2008-11-14 12:35 am (UTC)
From: [identity profile] terrycloth.livejournal.com
Right -- a blank cell is different than a cell with value 0 or value '0 length string'. The underlying database engine probably has special blank-handling formulas, maybe Crystal Reports does too?

Date: 2008-11-14 02:04 am (UTC)
From: [identity profile] the-vulture.livejournal.com
'Master Reset' - That's what I'd do if it was a cellphone. Seriously, it looks like a bug.

Date: 2008-11-14 03:56 am (UTC)
From: [identity profile] postrodent.livejournal.com
Whooa, time snap! Would you believe that one of my very first jobs was writing and formatting Crystal Reports, in 1995 or so? My mom got me the job, since I'd never seen it before then -- rather naked nepotism. Anyway, I can't help you, but I do sympathize.

Date: 2008-11-14 04:25 am (UTC)
From: [identity profile] telnar.livejournal.com
If you can use raw SQL to generate the report (perhaps by editing the SQL generated by Cyrstal before using it), you could probably fix the incorrect handling of the NULL value. Is sounds like what you want (in ANSI SQL) is:

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)
From: [identity profile] tetsujinnooni.livejournal.com
(real programmers use patch panels to hotpatch running binaries, don'tcha know....)

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...

Date: 2008-11-14 02:08 pm (UTC)
From: [identity profile] bburnell.livejournal.com
I am certified in Crystal Reports 8.5, but alas I have been banished to SQL Reporting Services by my boss. Wish I could help. *sigh*

Try the CR forums at tekteps.com!

Hope that helps!

Re: I Are Not Reel Programr

Date: 2008-11-14 02:09 pm (UTC)
From: [identity profile] bburnell.livejournal.com
If I remember correctly, you have to check a bunch of things in Crystal, like isnull and len(trim(x)) = 0, etc...

December 2025

S M T W T F S
 123456
78910111213
141516 17181920
21222324252627
28293031   

Most Popular Tags

Active Entries

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 25th, 2025 10:39 pm
Powered by Dreamwidth Studios