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
).
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:
Invoke the Group and Sort Panel and group the report by the
CategoryID
data field:This action adds the GroupHeaderBand to the report and adds the GroupField to that band.
Click the Group Header band’s smart tag, and click the ellipsis button next to the GroupHeaderBand.SortingSummary property:
In the invoked Group Sorting Summary Editor, check the Enabled option, set the Field option to ProductName, and set the Summary function to Count.
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.
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.Specify that the detail band occupies three columns to save space in the report:
Preview the report to see the result.