Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Selecting a highest unique value Post Reply Post New Topic
Author Message
analyst12150
Newbie
Newbie
Avatar

Joined: 30 Dec 2011
Online Status: Offline
Posts: 5
Quote analyst12150 Replybullet Topic: Selecting a highest unique value
    Posted: 06 Nov 2012 at 5:13am
Ok, need some help here. I have a report that pulls a field called "table.COSTCATID" containing individual names associated with a particular project.  One of our projects, however, has multiple COSTCATIDs for each person, so each employee has many IDs with a number at the end (e.g. Name 55, Name 56, etc.).  I only need to pull one ID for each person b/c the salary, bill rate, etc is the same for each ID, unless a change is made on an indivual basis, which would be reflected in a new COSTCATID.
 
So here's my dilema... currently, to avoid having unnecessary IDs pulling in the report, Report Select Expert is set up to have the COSTCATID field as "not one of"... and I list all the extras.  Obviously, this is tedious each time new IDs are added. 
 
Is there a way to tell crystal to just pull the highest unique value of those field lines? I tried a maximum formula, but that just returned the single highest ID (such as Name 55) for each line item instead of everyone's highest value (such as Doe 17, Smith 3, Last 82, Name 55).
 
How can I get it to pull the highest unique value for each ID in that field?
 
*FWIW - the field is a text string field.


Edited by analyst12150 - 06 Nov 2012 at 5:14am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Nov 2012 at 5:21am
How are you pulling the data into the report?  Have you linked tables together, used a stored procedure, used a command, or used a universe?  What type of database are you getting the data from?
 
The most efficient way to do this is going to be to use a command, which is just a SQL select statement.  If I know the type of database, I should be able to come up with some sample SQL for you to do this.
 
-Dell
IP IP Logged
analyst12150
Newbie
Newbie
Avatar

Joined: 30 Dec 2011
Online Status: Offline
Posts: 5
Quote analyst12150 Replybullet Posted: 06 Nov 2012 at 5:28am
The report uses linked tables from Microsoft GP database (SQL).  However, I cannot edit the SQL query in the report, so I'm limited to Crystal's formula editor.
 
thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Nov 2012 at 5:59am
You can't edit the query as Crystal has built it - you would have to take the tables out and provide the whole query as a command (in the Database Expert, go to your connection and Create Command instead of selecting tables...).  The command needs to contain ALL of the data that you need in the report.
 
If you copy the SQL from Crystal here, I'll show you how to modify it for what you need.
 
-Dell
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.