The Result Data Newsletter   
Volume 803 - March 2008   
© Copyright 2008 Result Data Consulting, Ltd.  614-505-0770  www.resultdata.com   

    Result Data Home Page  |  Newsletter Archive  |  Upcoming Events  |  Classes & Workshops  |  Request Information
Upcoming Events:  Microsoft SQL Server User Group: 3/28, Mid Ohio BusinessObjects User Group: 5/7

Return to Newsletter Contents...

 

Crystal Reports 2008 Sort Controls

by: Sean Beal, Senior Consultant, CRCP

Out with the Old

Remember how we used to have to do ‘dynamic’ sorting?  That’s right; we created parameters to allow the report consumer to choose from available sorting options.  We could then use this parameter to drive a formula that returned a particular field based on if – then or case logic.  Finally, we sorted on this formula.  The disadvantage of this methodology was mainly the fact that every time a user wanted to view the report in a different way, a complete refresh and re-query of the database was necessary.  It also just had a ‘hackish’ feel and could only be done if you knew how to write formulas. 

In with the New

These limitations have been resolved in Crystal Reports 2008 with the introduction of the Sort Control. Let’s dive in and see how they work.  In order to do this, I’ve created a simple report based on the Xtreme sample database, using the Invoice table.  It looks like this:

Pic 1

The report is currently showing all data in the order in which it was entered into the database.   This is called ‘natural order’ or ‘original order’. 

The first step we need to take in order to allow users to dynamically change the sorting of this report with Sort Controls is to add record sorting to the report using the Record Sort Expert.  This is no different than how we used to add record sorting in the past; we’ll add it for each field on which we want the user to be able to dynamically sort:

Record Sort Expert

Choose ‘Ascending’ or ‘Descending’ sort directions on the fields depending on how you want the initial sort state of the report to appear.  When finished, click ‘OK’.

Next, we need to create the Sort Control itself.  We can do this one of two ways, using an existing text object (like a column header), or by creating a new text object.  To use an existing text object, simply right click on the object, select ‘Bind Sort Control’, select the sort field to which you’d like to bind and click ‘OK’:

Pic 3

Pic 4

Repeat the steps above for any additional fields on which you would like to allow users to dynamically sort.  Your report should now look something like this:

Pic 5

Notice the Sort Controls to the right of each text object selected.  Of course, clicking on them alternates the sorting for that particular column.

There are some limitations to note (these are mentioned in the Crystal Reports Online Help).  If your report has grouping, the Sort Control will apply across the entire record set of the report; you cannot sort within a group and leave other groups unaffected.  Sort Controls cannot be used in sub-reports, and cannot be created within a Cross Tab or OLAP grid.  Finally, using Sort Controls will cause open drill down tabs to close.

Conclusion

Sort Controls are an excellent replacement of the old parameter-formula method of providing dynamic sorting.  They have the advantage of simplicity and do not re-query the database in order to re-sort the report.  If you are already using Crystal Reports 2008 in your environment, you owe it to your end users to check them out!

Go to Top  |  Return to Newsletter Contents

The Result Data Newsletter is published approximately once a month to share the latest information on business intelligence, data management and CRM. There should be a link below to allow you to change or remove yourself from our list. We take your requests very seriously. If you have any difficulty please contact us at 614-505-0770 and we will make sure that your request is handled properly. This is not intended to be an unsolicited message and you can reach us in person if needed.

© Copyright 2007 Result Data Consulting, Ltd. - All Rights Reserved
All trademarks and copyrights are the property of their respective owners. This information is provided without warranty.
Announcements
Save Big $$ On Gas This Spring
Schedule and attend any one of our qualifying public training classes from April through June 30th to receive up to $385 in gas cards OR  receive 10% off the normal class price.  Please contact our office for further details on promotion amounts and qualifying classes.   Restrictions apply and you must mention the promotional code Gas08 at the time of registration to receive the promotion.  Call 614-505-0770 for further details and restrictions.
Microsoft SQL Server User Group
Join us for the Spring Microsoft SQL Server User Group meeting on March 28th. Our main presentation will be by Luis Gonzalez of Microsoft demonstrating and discussing the new and exciting features in SQL Server 2008.  Call 614-505-0770 or click here for more information and to reserve your seat.
Louisville BI Seminar - Optimizing Company Performance Though Better BI
See how solutions from Business Objects can help organizations seeking to improve operational efficiency, sales effectiveness or financial performance.  This event will be held on April 24, 2008 at the Louisville Marriott East.  Call 614-505-0770 or click here for more information and to reserve your seat.
Mid Ohio BusinessObjects User Group
Join us for the Spring MOBOUG User Group meeting on May 7th. Call 614-505-0770 or click here for more information and to reserve your seat.
Looking for a Few Good Men and Women
Join our award winning team of Business Intelligence consultants and .Net Software developers.
Send your resume and salary requirements to:
jobs@resultdata.com