Solved

Using IsNull in Selection Formulas

Posted on 2008-11-03
10
2,068 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
  • 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 100

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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 250 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 100

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Problem Statement In an SAP BI BO Integration project when a BO universe is built on a BEx query, there can be an issue of unit & formatted value objects not getting generated in a BO universe for some key figures. This results in an issue whereb…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

943 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now