Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.08 Sorting in a Specified Order

Sorting In a Specified Order

The second dropdown box at the top selects the sorting order of how the groups are listed. With one exception, the sorting options are what you would expect and don’t need any explanation. You can choose a sort order that is Ascending, Descending, Original Order (no sorting) or Specified Order. The first three options are straightforward, but the Specified Order option requires more explanation.

Specified order means that you specify the exact order to display every value in that field. You manually go through each possible value and specify the order in which it appears on the report. If you leave any values out, then they all get consolidated into a single group that appears at the end of the report.

Once you select the Specified Order option, two new tabs appear in the dialog box: Specified Order and Others.



Figure 3-11. The Specified Order tab of the Insert Group dialog box.

The Specified Order tab is where you build the list of how the values are to be sorted. At the top is a dropdown box that lists all the possible values for the group field. Under the dropdown box is a list that shows which groups and their order.

There are two ways of adding items to the list: adding individual items or adding named groups (a sub-group). Adding individual items is the easiest method because you simply select a value from the dropdown box and it gets added to the list. The order that you add them to the list is the order that they appear on the report. If you want to rearrange where an item appears in the list, select the item to move and click on either the up or down arrows located to the right of the list.

If you have a lot of possible values, adding them all to the list could be very time consuming. For example, a sales report grouped by region would have a lot of values if it were for an international company. To make this a little easier, there is a faster way of adding items to the list.

The second way of adding items is by creating Named Groups that specify a range of values. It may be easier to think of this as a sub-group. Specifying a named group is done by specifying a lower and upper bounds for the range or building a formula using Boolean logic. Any value that falls within this range is included in the named group. This is obviously a faster way of adding the items because one sub-group can consist of many values. Named groups also give you a lot of flexibility because the formulas can be quite complex.

Be careful that you don’t add an individual item that could also fall within the classification of a named group. If this happens, the data will appear in both the named group and listed separately. This effectively doubles the data and gives incorrect summaries. Always check that the formula used in a named group doesn’t accidentally include individual items already listed.

To create a Named Group, click on the New button located below the list. This brings up the dialog box called Define Named Group. You can see in Figure 3-12 that this is a fairly simple dialog box.



Figure 3-12. The Define Named Group dialog box.

Assign a name to the group in the top input box. This name is what will be displayed on the report in the group header. In the left dropdown box you specify how to filter the range of values. The dropdown box shows numerous ways to select a range of values. A few of these are: Is Equal To, Is Not One Of, and Is Between. When you select one of these operators, the proper input controls automatically appear to the right of the dropdown box. The input controls change depending upon the information needed to complete the filter. There are so many different variations of filtering options and their associated input controls, that they won’t be explained here. They are all very intuitive and you shouldn’t have any problem entering the proper data.

Within a named group, you have the option of using more than one filter. By clicking on the tab, you are shown the same filtering options as on the first tab. But now you can make new selections and the resulting values are also associated with the current named group. These filters are linked together using an OR operand. Thus, any of conditions can be true and the record will be included in the named group.