Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: record selection Post Reply Post New Topic
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: record selection
     Posted: 01 Apr 2013 at 9:21am
I'm trying to filter my record selection to

{field} = CONVERT(UNIQUEIDENTIFIER, RIGHT(CONVERT(VARCHAR(MAX), {field}), 36))

i'm unable to make this happen so far. this works in sql but i can't quite figure it out in crystal.

any help would be amazing!

thank you!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 Apr 2013 at 6:30am
The way to do this depends on how you are getting the data for your report.  Are you using linked tables, command, universe, or a stored procedure?
 
-Dell
 
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 03 Apr 2013 at 6:32am
linked tables
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 Apr 2013 at 9:00am
Ok, here's what you'll do:
 
1.  Create a SQL Expression.  I'll call this {%Filter}.
 
CONVERT(UNIQUEIDENTIFIER, RIGHT(CONVERT(VARCHAR(MAX), 'Table'.'Field'), 36))
Select the field that you want to use from the list in the editor instead of just typing it - that way you'll get the correct format on it.  This is SQL syntax instead of Crystal or Basic syntax.
 
2.  In the Select expert, select the field that you want to compare, "is equal to".  Then edit the formula.  Initially formula will look something like:
 
{field} = ""
 
change it to
 
{field} = {%Filter}
 
-Dell
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 04 Apr 2013 at 11:01am
so i'm having a little trouble. i'm not exactly sure how a sql expression differs from a new formula field. 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Apr 2013 at 11:34am
A SQL Expression is evaluated in the database and uses the syntax from your database.  A Formula uses either Crystal or Basic syntax and it evaluated in the report.
 
For your situation, if you try to filter your data on a Formula, Crystal will pull ALL of the data into memory and then filter it there.  This can cause a significant performance decrease, especially if you have a lot of rows of data.  If you use a SQL Expression, the filter will be pushed to the database and the query will return fewer records, making the report faster.
 
-Dell
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 05 Apr 2013 at 3:07am
when i go to add a sql expression i'm finding that i don't have the sql expression button in field explorer...is there any other way to add it?
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 10 Apr 2013 at 9:33am
any other possible thoughts on how to filter the data on those 2 fields? since i'm linked to 2 different databases i don't have the option of using a sql expression. it's the last piece to get this report to work perfectly. any help or suggestions would be great. thank you!
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