SAP Knowledge Base Article - Public

1534841 - Sort records in Crystal Report dynamically in Ascending or Descending order

Symptom

  • Dynamically Sort Records in a Report based on User's selection in Parameter object
  • Sort Records in a Crystal Report in Ascending or Descending order based on User's Selection

Environment

  • Crystal Reports  XI Release2
  • Crystal Reports 2008

Resolution

  1. Use 'Command Object' to fetch the data
  2. Launch Crystal Reports and connect to  "Xtreme" sample Database
  3. Add a Command Object
  4. Create a parameter in Command Object query with name "sort order"
  5. Add the following Command in the Command Object                                                                              

                SELECT  `Customer`.`Region`, `Customer`.`Country`
                FROM   `Customer` `Customer`
                ORDER BY `Customer`.`Country``{?sort order}`

    6.When the Report is refreshed, the user can pass "Asc" or "Desc" into the Parameter to Sort the Records Dynamically

Keywords

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

Product

SAP Crystal Reports all versions