[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]Office File API
 [Expand]Product Information
 [Expand]Get Started with DevExpress Reporting
 [Expand]Create Popular Reports
 [Collapse]Detailed Guide to DevExpress Reporting
   Introduction to Banded Reports
  [Expand]Provide Data to Reports
  [Expand]Use Report Controls
  [Collapse]Shape Report Data
   [Expand]Filter Data
   [Collapse]Group and Sort
     Group and Sort a Report's Data
     Group Data by a Custom Field
     Group Data by Days of the Week
     Sort Data by a Custom Field
     Sort Groups by a Summary Function's Result
     Sort Data (Runtime Sample)
     Group Data (Runtime Sample)
     Group Data by Days of the Week (Runtime Sample)
   [Expand]Shape Data (Expression Bindings)
   [Expand]Shaping Data (Legacy Data Bindings)
   [Expand]Use Calculated Fields
   [Expand]Use Report Parameters
   Arrange Dynamic Report Contents
  [Expand]Customize Appearance
  [Expand]Add Navigation
  [Expand]Provide Interactivity
  [Expand]Add Extra Information
  [Expand]Merge Reports
  [Expand]Use Expressions
  [Expand]Store and Distribute Reports
  [Expand]Reporting API
 [Expand]Visual Studio Report Designer
 [Expand]Create End-User Reporting Applications
 [Expand]API Reference
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Group and Sort 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.


    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.


    See Sort 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.


    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 footer's Band.PageBreak property to AfterBand, or place the XRPageBreak control at the band's bottom.

    See Add 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 Sort a Report in Print Preview for more information.

Expanded See Also

Is this topic helpful?​​​​​​​