Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

4.04 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.

Specified Order is the option that is not completely intuitive. Specified Order means that you specify the exact order to display every possible data value in that field. Once you select this option two new tabs appear in the dialog box: Specified Order and Others. This is shown in Figure 4-4.



Figure 4-4. 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. There are two controls in this dialog box. To top control is a dropdown box that lists all the possible values for the group field. The lower control is a listbox which shows the order that each value is to be listed in. Take values from the dropdown box and add them to the listbox in the appropriate order.

The order of the items in the listbox can be changed. Select the item to move and click on either the up or down arrows located to the right of the listbox.

There are two ways of adding items to the list box: adding individual items or adding named groups (a sub-group). Adding individual items is the easiest method because you simply click on one of the values from the dropdown box and it gets added to the list. Unfortunately, if you have a lot of possible values, this could be very time consuming. To make this a little easier, there is a second way of adding items to the list.

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

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 4-5 that this is a fairly simple dialog box.



Figure 4-5. The Define Named Group dialog box.

Assign a name to the group in the top textbox. In the left dropdown 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. From a Boolean logic standpoint, these filters are linked together using an OR operand. Thus, any of them can be true and the record will be included in the named group.

The last tab in the Change Group Options dialog box is the Others tab. Since it is very possible that some reports won’t need to specify how every value will be grouped, this tab is used to accumulate all the remaining values that didn’t get included in one of the named groups.

This is also useful for reports that group on fields where the data is dynamic and new values are being added. If the new values don’t fall within the current named groups, they get associated with the group called Other.

Values in the Other group can either be excluded from the report or included in the report. If they are included in the report then they are always listed as the last group.