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
Solved

Using IsNull in Selection Formulas

Posted on 2008-11-03
10
2,070 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
How to increase the row limit in Jasper Server.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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