Print Page | Close Window

first and last records

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=13172
Printed Date: 01 May 2024 at 2:54pm


Topic: first and last records
Posted By: dashamit
Subject: first and last records
Date Posted: 11 May 2011 at 5:40am
Hi Friends, How to get the first and last records from each unsorted groups in crystal reports?



Replies:
Posted By: DBlank
Date Posted: 11 May 2011 at 5:45am
for display purposes only just move the fields you want to see into the GHeader (first record) and GFooter (last record)


Posted By: dashamit
Date Posted: 11 May 2011 at 7:30am

But what is the method to identify the first and last values of individual field.

My requirement here is to show the First and last fields as summary.
For example
 
       DescColumn   ColumnA-First   ColumnB-Last
   GroupA
           A                        5                        3
           A                        8                        9
           A                        4                        1
      ----------------------------------------------------------
   Summary                                           1
   GroupB
           B                        7                        2
           B                        3                        9
           B                        6                        6
      ----------------------------------------------------------
   Summary                    7                        6
 
 


Posted By: DBlank
Date Posted: 11 May 2011 at 7:48am

again for just display purposes

make 2 running totals
name=First
field to summarize=column A
type of summary=SUM (assuming these are numeric fields)
Evaluate = On change of group (wahtever your grouping is)
Reset =On change of Group (same group as above)
 
Name=last
field to summarize=column b field
type= sum
evaluate = use a formula
next(descfield) <> descfield or onlastrecord
reset=on change of group
 


Posted By: DBlank
Date Posted: 11 May 2011 at 7:48am
both RTs have to be placed in the group footer to display correctly


Posted By: dashamit
Date Posted: 11 May 2011 at 8:46am
 Hi, managed to get the last values using the below formula.
  if( mailto:%7b@sumLAST - {colB}<>previous({colB })) then mailto:%7b@sumLAST - {colB }
 
Could you please explain a bit more on getting the first value, (ColumnA in the example).
 
"name=First
field to summarize=column A
type of summary=SUM (assuming these are numeric fields)
Evaluate = On change of group (wahtever your grouping is)
Reset =On change of Group (same group as above)"


Posted By: DBlank
Date Posted: 11 May 2011 at 8:51am
in the Field Explorer fine 'Running Total Fields'
Right click on it and select NEW
a window opens up
RT name =FIrst value (or whateer you want)
field to summarize = select the column A field for this
Type of SUmmary = select SUM
Evaluate section
select On change Of Group toggle option and then in the pick list sleect the group name here
Reset section
select On change Of Group toggle option and then in the pick list sleect the group name here

Save it.
Drag it and drop it on the group footer
 


Posted By: dashamit
Date Posted: 11 May 2011 at 9:39am
Thanks a lot DBlank!!! You made my Day today...
Looking forward to create and add the running totals fields using Java Sdk. It will helpful if you have some sample code on this.


Posted By: Farhan
Date Posted: 13 Jun 2012 at 11:16pm
Thanks

dear I applied same logic its working perfectly but i cannot access last record of report. it works on all records and group change but not on lastrecord of report. please guide me


Posted By: Farhan
Date Posted: 13 Jun 2012 at 11:18pm
For example
 
       DescColumn   ColumnA-First   ColumnB-Last
   GroupA
           A                        5                        3
           A                        8                        9
           A                        4                        1
      ----------------------------------------------------------
   Summary                                           1
   GroupB
           B                        7                        2
           B                        3                        9
           B                        6                        6
      ----------------------------------------------------------
   Summary                    7                    (cant see 6 here)


Posted By: Farhan
Date Posted: 13 Jun 2012 at 11:32pm
Thanks your discussion was really helpful and I found solution by this

Name=last
field to summarize=column b field
type= sum
evaluate = use a formula
if onLastRecord then true else next(descfield) <> descfield
reset=on change of group
 
Instead of

Name=last
field to summarize=column b field
type= sum
evaluate = use a formula
next(descfield) <> descfield or onlastrecord
reset=on change of group
 




Print Page | Close Window