Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Collapse]Reporting
 [Expand]Product Information
 [Collapse]Creating Reports in Visual Studio
  [Expand]Adding a Report to Your .NET Application
  [Expand]Getting Started with DevExpress Reporting
  [Collapse]Detailed Guide to DevExpress Reporting
   [Expand]Storing and Distributing Reports
   [Expand]Providing Data to Reports
   [Collapse]Shaping Report Data
    [Expand]Data Filtering
    [Collapse]Grouping and Sorting
      Grouping and Sorting a Report's Data
      Grouping Data by a Custom Field
      Grouping Data by Days of the Week
      Sorting Data by a Custom Field
      Sorting Groups by a Summary Function's Result
      Sorting Data (Runtime Sample)
      Grouping Data (Runtime Sample)
      Grouping Data by Days of the Week (Runtime Sample)
    [Expand]Shaping Data using Binding Expressions
    [Expand]Shaping Data using Legacy Data Bindings
    [Expand]Using Calculated Fields
    [Expand]Using Report Parameters
   [Expand]Report Navigation, Interactivity and Appearance
   [Expand]Reporting API
  [Expand]Detailed Guide to Visual Studio Report Designer
 [Expand]Creating End-User Reporting Applications
 [Expand]API Reference
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Grouping and Sorting a Report's Data

This document describes how to group and/or sort data in your report:

Expanded Group and Sort a Report's Data

Do the following to group and/or sort data in your report:

  1. Create a new or open an existing data-bound report.

    You cannot apply grouping unless your report is bound to a data source.

  2. Switch to the Group and Sort panel, click Add a Group and select the required data field in the invoked drop-down menu.

    Tip

    See the following tutorials to learn how to sort a report's data by a custom field:

    This creates an empty group header with a corresponding group field added to its GroupHeaderBand.GroupFields collection.

    You can access this collection by clicking the group header's smart tag:

    You can use the Group Field Collection Editor to group data by multiple criteria. Click Add to create a new group field in this editor and specify its GroupField.FieldName property.

    Use the up and down arrow buttons to specify the order in which these criteria are applied to the report's data.

  3. Back in the Group and Sort panel, you can specify the group fields' sorting order (ascending or descending).

    Select None if your groups are already ordered in the data source, and you do not need to sort them in the report.

    Tip

    See Sorting Groups by a Summary Function's Result to learn how to sort groups by a summary.

  4. Click Show Footer to create an empty footer for this group.

    Tip

    Disable the Show Header and Show Footer options to sort the report's data without displaying any headers and footers.

  5. When a report has multiple groups, you can change their order by clicking Move Up or Move Down.

    The following images illustrate how a report looks when it is grouped by multiple criteria:

    A single group with multiple group fields Nested group header bands
  6. Drag the corresponding field from the Field List and drop it onto the group footer to display the group field's value in the report.

The resulting report looks as follows:

Expanded Specify the Group's Settings

You can use the group band's smart tag to customize the group's layout settings:

  • Use the GroupHeaderBand.GroupUnion property to keep a group's content on the same page when possible.

  • Use the Band.KeepTogether property to print the group header/footer on the same page as the group's contents.

  • Use the GroupBand.RepeatEveryPage property to print the group band on each page.

  • Use the Band.PageBreak property to start a new page before or after each group.

  • When you need to display page numbers for individual groups, add the XRPageInfo control to the group header or footer and set its XRPageInfo.RunningBand property to the group header's name.

    Accurate page numbering requires that different groups do not appear on the same page. For this reason, you need to set the group header's Band.PageBreak property to AfterBand, or place the XRPageBreak control at the band's bottom.

    See Adding Page Numbers to learn more.

Expanded Interactive Sorting in Print Preview

You can allow end-users to sort report data directly in Print Preview by clicking a designated element.

See Sorting a Report in Print Preview for more information.

Expanded See Also

How would you rate this topic?​​​​​​​