SAP Knowledge Base Article - Public

2888751 - How to display the latest record in Crystal Reports?

Symptom

  • How to show the last update?
  • How to display the most up to date row of data in Crystal Reports for something specific?
    For example: Last dentist visit per client, last order per customer, ...

Environment

  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Resolution

  • The most efficient way to display the latest data for something specific, is to write a SQL Query, but it is possible to display the latest row of data by creating a group on the database field you want to see the latest row of information for, then sort the records on a date or time database field in ascending order, and finally insert the database fields to display in the Group Footer section. 
             
    1. In Crystal Reports, create a report based on your data source.
              
    2. Insert a group on the database field you want to see the latest row of information for. 
      1. 2.1  Under the menu "Insert", select "Group..."
      2. 2.2  In the "Insert Group" window, select the database field that contain a unique idendifier for the value you want to see the lastest row of information for.
               For example: Client Number, Customer Number, Student Number, ....
      3. 2.3  Click "OK"
                     
    3.  Sort the records in Ascending order on a date or time database field.
      1. 3.1  Under the menu "Report", select "Record Sort Expert..."
      2. 3.2  In the "Record Sort Expert" window, add the date or time database field to the "Sort Fields" area.
      3. 3.3  Set the "Sort Direction" to "Ascending"
      4. 3.4  Click "OK" 
                   
    4. In the Group Footer section, insert all the database fields you want to display the latest information for.
          
    5. Suppress the Group Header, and Details section.
               
      When refreshing the report, it will display the latest rows of data for each group, because database fields inserted in the Group Footer section displays the last row of data for the group.
        
        
  • Sample report demonstrating the above technique is available in the Attachments section below.

Keywords

CR, Crystal Report , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 2013 ; SAP Crystal Reports 2016

Attachments

Latest row of data.rpt