Solved

Using IsNull in Selection Formulas

Posted on 2008-11-03
10
2,069 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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