Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Help Post Reply Post New Topic
Author Message
psalm19
Groupie
Groupie
Avatar

Joined: 19 Feb 2009
Online Status: Offline
Posts: 48
Quote psalm19 Replybullet Topic: Formula Help
     Posted: 26 May 2010 at 12:29pm
I'm sure there's already an answer on this forum for this seemingly simple problem but am not sure what keywords would pull the results I'm looking for so I'm hoping someone can help me out.

Running CR 10 Pro.

The report I'm working on includes Accounts, Service Orders and Contracts with the desired end result being to show all Accounts with Service Orders that have had work done that are either have never had a warranty or their warranty has expired.

So the report is configured to pull for specific records (Expired, Renewal sent, and Not Renewed ) in a field tblContract.Status which works for Accounts that have had a contract but it doesn't pull those that have never had a Contract. The current formula looks like this...

{tblContracts.Status} in [" ", "Expired", "Not Renewed", "Pending", "Renewal Sent"]

I was hoping this inclusion (" ",) at the beginning of the forumula would fix my issue but it did not. Any suggestions are appreciated!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 26 May 2010 at 5:00pm
if you are joining this from another table you would need to do an outer join.
If you change the formula to use 'default values for NULLS' then change your " " to "" and it should work or
use
isnull({tblContracts.Status}) or {tblContracts.Status} in ["Expired", "Not Renewed", "Pending", "Renewal Sent"]
IP IP Logged
psalm19
Groupie
Groupie
Avatar

Joined: 19 Feb 2009
Online Status: Offline
Posts: 48
Quote psalm19 Replybullet Posted: 27 May 2010 at 5:41am
DBlank,
Thanks for the suggestions, all of the tables in the report are set to left outer join. I adjusted the formula with the one you suggested and now its retrieving every Service Order in the database which is odd as I have a statement that tells it to only pull 3 orders, for testing purposes.

IsNull({tblContracts.Status}) or {tblContracts.Status} in ["Expired", "Not Renewed", "Pending", "Renewal Sent"]

I noticed when I go into Report Expert I get a message that says, "Formula contains a composite expression use Formula editor for editting". I've never seen that message before.

Any ideas on why this is happening?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 May 2010 at 6:25am

outer joins can become inner joins based on select criteria.  also crystal joins are not 'activated' (enforced) unless you either force it in the join options or until you use a field from both tables in the join.

Did you use an OR statement with your testing as something like...
table.orderID in (1,2,3) OR IsNull({tblContracts.Status}) or {tblContracts.Status} in ["Expired", "Not Renewed", "Pending", "Renewal Sent"]
That would explain your large data set being returned.
IP IP Logged
psalm19
Groupie
Groupie
Avatar

Joined: 19 Feb 2009
Online Status: Offline
Posts: 48
Quote psalm19 Replybullet Posted: 27 May 2010 at 6:34am
So in the report I've configured the join types using "link options and below is the formula I used.

{tblServiceOrders.SONumber} in [266465, 266780, 266855] and
IsNull({tblContracts.Status}) or {tblContracts.Status} in ["Expired", "Not Renewed", "Pending", "Renewal Sent"]
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 May 2010 at 6:39am

I assume there is an SO# in tblContracts which is what you are joining on.

try and parenth the OR
{tblServiceOrders.SONumber} in [266465, 266780, 266855] and
(IsNull({tblContracts.Status}) or {tblContracts.Status} in ["Expired", "Not Renewed", "Pending", "Renewal Sent"])
IP IP Logged
psalm19
Groupie
Groupie
Avatar

Joined: 19 Feb 2009
Online Status: Offline
Posts: 48
Quote psalm19 Replybullet Posted: 27 May 2010 at 7:23am
Adding the parens seems to have done the trick for the formula. I noticed it was still pulling all records so I made some adjustments to the links and now the report seems to be working properly.

I really appreciate your insight and "staying power"! I'm curious, you're always quick with your responses and are obviously very knowledgeable with databases/CR, do you work for this site or are you simply an amazing "volunteer"?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 May 2010 at 7:49am
Just "volunteering".
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum