Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Conditional Select Expert Use Post Reply Post New Topic
Author Message
jpterry
Newbie
Newbie
Avatar

Joined: 09 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jpterry Replybullet Topic: Conditional Select Expert Use
     Posted: 05 Apr 2012 at 10:03am
I have a report that pulls in mulitple companies worth of data. I want to allow the user to select a specific company (via drop-down menu) or select "ALL" (which is an option in the drop-down). In the Select Expert I placed:
 
IF ({?Company} <> 'ALL') Then
 {Tablename.Company} = {?Company)
 
This works for selecting individual companies, but does NOT ignore the IF Statement for ALL companies (no data is returned.
 
Does anyone know how to SKIP the Select Expert conditionally?
 
IP IP Logged
jpterry
Newbie
Newbie
Avatar

Joined: 09 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jpterry Replybullet Posted: 05 Apr 2012 at 10:21am
Add this to the statement:
if ({?Company} <>  'ALL') then
  {Tablename.Company} = {?Company}
else
  {Tablename.Company} like '*'
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Apr 2012 at 10:40am
just use this
{?Company} =  'ALL' or {Tablename.Company} = {?Company}
IP IP Logged
jpterry
Newbie
Newbie
Avatar

Joined: 09 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jpterry Replybullet Posted: 05 Apr 2012 at 12:28pm
I have to admit that I was doubtful that it would work, but it does! Would you be so kind as to explain the logic there, especially compared the original.  JPT

Edited by jpterry - 05 Apr 2012 at 12:28pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Apr 2012 at 3:31pm
First I have to thank hilfy for setting me straight on this process.
It is best to avoid using if-then statements in the select expert. It is only wanting a Boolean result.
True include or False exclude.
The first part, ?company='all', evaluates to true when user selects 'all'. Once it hits true it stops evaluating. Since it is true it has no filtering impact on your records which is the similar to telling it to use the like '*' . It evaluates quicker because it does not need to look at each row.
If the user does not select 'all' it evaluates to false and moves to the second part of the or statement which in turn only returns the company entered by the user.
Does that help?

Edited by DBlank - 05 Apr 2012 at 3:34pm
IP IP Logged
jpterry
Newbie
Newbie
Avatar

Joined: 09 Feb 2012
Location: United States
Online Status: Offline
Posts: 25
Quote jpterry Replybullet Posted: 07 Apr 2012 at 10:29am
Great answer! Thank you.  JPT
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