Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Diff Between First and Last Record in Group Post Reply Post New Topic
Author Message
rcurley
Newbie
Newbie


Joined: 01 Jun 2014
Location: United States
Online Status: Offline
Posts: 1
Quote rcurley Replybullet Topic: Diff Between First and Last Record in Group
     Posted: 03 Jun 2014 at 5:04am
Need some help in a formula to get the difference between the first and last record values in a group. For example, given the data:
MemberID   AssessDate   AssessValue
1          1/1/2000     10
1          1/15/2000    13
1          1/30/2000    15
2          1/6/2000     60
2          2/15/2000    30
2          2/16/2000    75
2          3/18/2000    80
3          1/2/20000    40
3          2/10/2000    42

I would want to see a grouping by the memberID, and within the details of the group I want to see all the dates and scores, but on the group footer I would want to see the difference from the first AssessValue and the last AssessValue. So, for member #1, I would see 5, for member 2, I would see 20, for member 3 it would be 2.

The AssessDates will vary for all MemberID's and the number of records per group/member will be different, with some having 2 and others having 10+.

Any help is greatly appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Jun 2014 at 6:00am
you can use two running totals with evaluation formulas to get the first and last record then suibtract those
//RT1
field to summarize=assessvalue
type=min
evaluate=use a formula
minimum(assessdate,memberid)=assessdate
reset=on change of group (memberid)
 
//rt2
same but evalaute formula is
maximum(assessdate,memberid)=assessdate
 
Rt2-Rt1 gives your value
Youc an alsu use shared variables with asimilar evaluate or a next(memberid)<>memberid in as a condition
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