Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Show most recent data on one line Post Reply Post New Topic
Author Message
VStevens
Newbie
Newbie


Joined: 24 Dec 2008
Online Status: Offline
Posts: 12
Quote VStevens Replybullet Topic: Show most recent data on one line
     Posted: 24 Dec 2008 at 6:58am
I am fairly new to CR, only been using it for about 9 months, so please bear with me.  My table has the IDNUM, then TYPE, RATE, and DATE.  The TYPE can be either A or B.  For example, the data could be:

IDNUM   TYPE     RATE    DATE
001        A          1           12/1/08
004        A          2           9/1/08
001        B          10         12/2/08
002        B          5           11/5/08
003        A          7           11/10/08
003        B          6           11/15/08
002        B          6           11/19/08
004        A          15         12/01/08
.
.
.
ECT...

I am looking to create a report that will give me the most recently updated info for both TYPEs on line line, while not displaying any data for previous dates.

for example, the above data would give:
IDNUM       TYPE A RATE    DATE           TYPE B RATE     DATE
001                       1          12/1/08                  10         12/2/08
002                                                                  6           11/19/08
003                       7          11/10/08                 6           11/15/08
004                       15        12/01/08
.
.
.

I have in the past, I have put the fields in the group footer, sorted by date to give me the most recent date, but I can't seem to get both of the most recent dates to show using this method.  I'm having trouble getting both TYPEs on to one line.

Any suggestions?  Please let me know if this is not clear.  Thank you.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 24 Dec 2008 at 10:05am

This will get a little complicated, but I think this will work.

1.  You'll need 3 copies of your table.  When you try to add a additional copy of a table to a report, Crystal will tell you that the table has already been added and ask if you want to add an Alias - click on 'Yes'.  You'll now see two entries in the list of tables for the report - the second will have the table name with "_1" after it, the third "_2", etc. We'll use the first one to get all of the ID numbers regardless of which "type" they contain so that you can get all records that have only Type A, all that have only Type B, and all that have both.  The second will be for the Type A records and the third will be for the Type B records.
 
2.  Link from the original copy of your table to the _1 copy on IDNUM and make the link a Left Outer Join.  Do the same for the _2 copy of the table.
 
3.  Create a group on IDNUM.
 
4.  Add descending sorts on the date filed for both the _1 and _2 tables.
 
5.  In the Select Expert, add conditions for {Table_1.Type} = 'A' and {Table_2.Type} = 'B'.
 
6.  In the group head section for the IDNUM, put your data in the layout that you show above.
 
7.  Suppress the details.
 
Because you've sorted the Type A and Type B data in descending order by date, the first record returned in the report should contain the most recent Type A and Type B records.
 
There's also a way to do this using subreports, but that will tend to slow down the report.  If you have to display other detail data besides what's in your example, you'll probably have to use subreports for this.
 
-Dell
IP IP Logged
VStevens
Newbie
Newbie


Joined: 24 Dec 2008
Online Status: Offline
Posts: 12
Quote VStevens Replybullet Posted: 24 Dec 2008 at 10:33am
This is exactly what I was looking for!  I'm going to post your answer on the other forum where I posted my question.  https://www.sdn.sap.com/irj/scn/forum?forumID=300
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