Solved

Crystal Reports 11 - if-then syntax question SQL Server 2005

Posted on 2011-02-23
2
519 Views
Last Modified: 2012-05-11
Hello experts,

In a formula field, I have t he below syntax:

If {@RefType} = 'P' then {@Guarantor Name} else
If {@RefType} = 'I' and left({transactions.tracking_desc_40},1) = 'D' then 'DMERC Region B' else
If {@RefType} = 'I' and (left({transactions.tracking_desc_40},1) <> 'D' or {transactions.tracking_desc_40} = '' or isNull({transactions.tracking_desc_40})) then {payer_mstr.payer_name} else
''

This seems to function accurately when {transactions.tracking_desc_40}  starts with 'D', but when it's blank or null, it doesnt print payer_mstr.payer_name column, and we have verified that there is indeed a value in the payer_mstr.payer_name column as we have unhid it directly on the report.

Is there a problem with the way we have structured the nested if statements?

Thanks!
0
Comment
Question by:robthomas09
[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
2 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 34965863
You have to test the NULL condition first.  Any test on  a NULL value except IsNull terminates the formula with undefined result.  Try it this way

If {@RefType} = 'P' then
     {@Guarantor Name}
else If {@RefType} = 'I' and ( isNull({transactions.tracking_desc_40}) or
                                                       {transactions.tracking_desc_40} = '' or
                                                  left({transactions.tracking_desc_40},1) <> 'D') then
    {payer_mstr.payer_name}
else If {@RefType} = 'I' and left({transactions.tracking_desc_40},1) = 'D' then
   'DMERC Region B'
else
   ''

mlmcc
0
 

Author Closing Comment

by:robthomas09
ID: 34966477
Thanks!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…

707 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