?
Solved

Using IsNull in Selection Formulas

Posted on 2008-11-03
10
Medium Priority
?
2,073 Views
Last Modified: 2013-11-15
I'm working on a report where I have a join between two tables that is producing null values (Party and Donations).  I want to include the nulls, so I've used IsNull in the selection formula to make this happen.  I've even been careful enough to put it at the very front of the formula, since this seems to be the only way to make Crystal return nulls.  However, I'm not getting the results I expect from the rest of my selection formula.  I'm trying to exclude inactive parties and parties that are organizations.  While I seem to be excluding the inactives, getting Crystal to exlcude parties that are organizations is just not working.  I've tried changing the order of my selection formula, but to no avail.  Any suggestions?
IsNull({Campaigns.CampaignYear}) = True or 
{Party.IsOrganization} = False and
{Party.IsActive} = True and {Campaigns.CampaignYear} = "2008"

Open in new window

0
Comment
Question by:gsszuber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22868496
Try adding parentheses to ensure that the correct and/or logic is being followed.  Crystal does not exclude nulls unless you tell it to.

IsNull({Campaigns.CampaignYear}) = True or
(
{Party.IsOrganization} = False and
{Party.IsActive} = True and {Campaigns.CampaignYear} = "2008"
)
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22869648
The ( ) should resolve the issue.  If not
How are the tables joined?

Can you give some sample data that is causing the problem

mlmcc
0
 
LVL 26

Expert Comment

by:Kurt Reinhardt
ID: 22869763
Also, you don't need the "= True" (it doesn't hurt, but it's redundant).  Try this simpler syntax:



IsNull({Campaigns.CampaignYear}) or 
({Party.IsOrganization} = False and
{Party.IsActive} = True and {Campaigns.CampaignYear} = "2008")

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gsszuber
ID: 22870463
Unfortunately adding the parens seems to have no effect.  Also, if I take out the IsNull({Campaigns.CampaignYear}) = True, then it get rid of all parties that do not have a donation.  I'm beginning to think this is a bug more than a mistake in logic.

As far as a workaround, I tried conditionally suppressing rows in the detail section and that seems to work, but I don't particularly like doing it this way.  Now some of my summary calculations will have to be redone.
0
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 22871370
Are you sure Campaigns.CampaignYear is null and not just blank spaces?
0
 

Author Comment

by:gsszuber
ID: 22871592
Since Campaigns.CampaignYear is linked to Party through Donations with a right outer join, I would say that, yes, I am certain SQL Server is returning nulls instead of blank spaces.  I replicated the joins I have set up in Crystal in a SQL statement and confirmed this.
Links.png
SQL.png
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 1000 total points
ID: 22871717
What about using a SQL expression?
if the SQL expression is called CampaignYearSQL
ISNULL({Campaign.CampaignYear}, '2008')

record selection =
{Party.IsOrganization} = False and
{Party.IsActive} = True and CampaignYearSQL = "2008"


0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22872400
Is the where clause included in the SQL for Crystal?

If so Crystal changes all joins to INEER if the right table is used for selecting/filtering records.

mlmcc
0
 

Author Comment

by:gsszuber
ID: 22872793
Good call mlmcc, I was unaware of that.  I just looked at the SQL Query and it doesn't have a where statement.  I suppose this is because all my joins are outer joins.
 SELECT "Party"."NickName", "Campaigns"."CampaignYear", "Donations"."Amount", "Party"."SurnameOrgName", "Party"."IsActive", "Party"."IsOrganization"
 FROM   ("UnitedWay"."dbo"."Party" "Party" LEFT OUTER JOIN "UnitedWay"."dbo"."Donations" "Donations" ON "Party"."PartyID"="Donations"."PartyID") LEFT OUTER JOIN "UnitedWay"."dbo"."Campaigns" "Campaigns" ON "Donations"."CampaignID"="Campaigns"."CampaignID"

Open in new window

0
 

Author Closing Comment

by:gsszuber
ID: 31512947
Sweet!  This seems to have done the trick.  You syntax was just a little off, tho... CampaignYearSQL needs parens around the table and field names for it to work and you forgot the braces and percent sign for CampaignYearSQL in the selection formula.  The fact that this works and using a regular selection formula does not has me feeling not so confident in how Crystal handles nulls.   :<
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question