Solved

Using IsNull in Selection Formulas

Posted on 2008-11-03
10
2,067 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String 2. Set the Stored Procedure Parameter to varchar(max)  --<---- This part here is the key to it's success Example:    @cst_key var…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

11 Experts available now in Live!

Get 1:1 Help Now