Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Selecting the last record in a group Post Reply Post New Topic
Author Message
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Topic: Selecting the last record in a group
    Posted: 13 Feb 2013 at 9:35am
Is there a way to select (or at least only show) the last sequential record for a group?

For example I have a report that more or less looks like this

Group level 1
    Group level 2
          Record 1
          Record 2
          Record 3
          Record 4


I only want Record 4 to show in the Details section.

Any advice would be greatly appreciated.
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 13 Feb 2013 at 9:43am
To make this slightly more complicated. I also need to be able to add a Sum to the report footer for two different fields associated to the last record in each group. I figure I will deal with that once I get past this first hurdle though!
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 13 Feb 2013 at 10:07am
Okay I am a space monkey. I figured out how to show only the last record. I just sorted descending and then placed the field in the group header. Haha. So simple. Anyway... any idea on how to sum only the visible fields?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Feb 2013 at 10:08am
display is simple, just drop the fields onto the group footer
summing is more complicated.
You could use shared variables with next() functions possibly.
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 13 Feb 2013 at 10:42am
Summing certainly is complicated. I thought maybe I could do something with TopN where N=1, but I'm not getting anywhere with that.
Don't you have to declare the variable for shared variables? Would that work where X would be whatever value is stored in the record.

Thanks for the reply DBlank. It is getting late in the day. I will have to try again tomorrow with fresh eyes.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Feb 2013 at 11:02am
since you reversed your sort it should be pretty easy.
Right click on Running Totals
select new
name=whatever
field to summarize=whatever field you want to sum
type=sum
evaluate=on chaneg of group (pick group1)
reset=never if you want a report total
place in the report footer (RTs do ot work in headers)
 
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 14 Feb 2013 at 8:29am
As usual, your advice is perfect.

I am getting better at CR everyday and I am just amazed at how friendly and helpful everyone on this forum is. I really appreciate it!

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.