Skip to main content

Sort Groups by the Result of a Summary Function

  • 2 minutes to read

This topic shows you how to sort groups by the result of a summary function. In the report created in this tutorial, the groups are sorted by the number of records they contain (the summary function is Count).

Sort Groups by the Result of a Summary Function

In this example, the report is bound to the Products table of the sample Northwind database.

Do the following to group the report and sort the groups by number of items:

  1. Invoke the Group and Sort Panel and group the report by the CategoryID data field:

    Group and Sort Panel

    This action adds the GroupHeaderBand to the report and adds the GroupField to that band.

  2. Click the Group Header band’s smart tag, and click the ellipsis button next to the GroupHeaderBand.SortingSummary property:

    Group Header Tasks

  3. In the invoked Group Sorting Summary Editor, check the Enabled option, set the Field option to ProductName, and set the Summary function to Count.

    Group Sorting Summary Editor

    In this editor, you can define the sort direction of the group and whether to ignore Null values.

    Click OK to apply changes and close the dialog.

  4. Add data-bound labels to the bands, as shown in the following image. Specify the Count summary function to display the product count. For more information on summaries, review the following help topic: Summaries Overview.

    Data Bound Labels at the Bands

  5. Specify that the detail band occupies three columns to save space in the report:

    Detail Band Cccupies Three Columns

  6. Preview the report to see the result.

View Example: How to sort groups by number of records in the group