Add summary statistics  Chapter 23: Highlighting Information in DataWindow Objects

Chapter 22: Filtering, Sorting, and Grouping Rows

Sort the groups

You can sort the groups in a DataWindow object. For example, in a DataWindow object showing employee information grouped by department, you might want to sort the departments (the groups) by total salary.

Typically, this involves aggregate functions, as described in “Add summary statistics”. In the department salary example, you could sort the groups using the aggregate function Sum to calculate total salary in each department.

Figure 22-13: Group Sort button in the Properties view for a group header

StepsTo sort the groups:

  1. Click the group header bar in the Design view of the DataWindow painter.

    The mouse pointer displays as a double-headed arrow when it is positioned in the group header bar.

    After you click the group header bar, the General properties page for the group displays in the Properties view.

  2. Click the ellipsis button next to the Group Sort box.

    The Specify Sort Columns dialog box displays.

  3. Drag the column by which you want to sort the groups from the Source Data box into the Columns box.

    If you chose a numeric column, PocketBuilder uses the Sum function in the expression; if you chose a non-numeric column, PocketBuilder uses the Count function.

    For example, if you chose the Salary column, PocketBuilder specifies that the groups will be sorted by the expression sum(salary for group 1):

    Figure 22-14: Sorting a group based on the sum of group salaries

  4. Select ascending or descending sort as appropriate.

  5. If you want to modify the expression to sort on, double-click the column in the Columns box.

    The Modify Expression dialog box displays.

  6. Specify the expression to sort on.

    For example, to sort the department group (the first group level) on average salary, specify avg(salary for group 1).

  7. Click OK.

    You return to the Specify Sort Columns dialog box with the expression displayed.

  8. Click OK again.

    At runtime, the groups will be sorted on the expression you specified.





Copyright © 2004. Sybase Inc. All rights reserved. Chapter 23: Highlighting Information in DataWindow Objects

View this book as PDF