Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Collapse]Spreadsheet
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Spreadsheet Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Table Overview
   [Expand]Charting Overview
    Printing
    Events
   [Expand]Mail Merge Overview
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
   [Expand]Shortcuts
   [Collapse]Examples
    [Expand]Files
    [Expand]Workbooks
    [Expand]Worksheets
    [Expand]Rows and Columns
    [Expand]Cells
    [Expand]Formulas
    [Expand]Import and Export Data
    [Expand]Data Binding
    [Expand]Mail Merge
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Tables
    [Collapse]Pivot Tables
      How to: Create a Pivot Table
      How to: Refresh a Pivot Table
      How to: Change a Data Source for a Pivot Table
      How to: Move a Pivot Table
      How to: Clear or Remove a Pivot Table
      How to: Change the PivotTable Layout
      How to: Subtotal Fields in a Pivot Table
      How to: Display or Hide Grand Totals for a Pivot Table
      How to: Apply a Predefined Style to a Pivot Table
      How to: Apply a Custom Style to a Pivot Table
      How to: Control Style Options
      How to: Change the Summary Function for a Data Field
      How to: Apply a Custom Calculation to a Data Field
      How to: Create a Calculated Field
      How to: Create a Calculated Item
      How to: Sort Items in a Pivot Table
      How to: Filter Items in a Pivot Table
      How to: Group Items in a Pivot Table
    [Expand]Printing
    [Expand]Pictures
    [Expand]Charts
    [Expand]Protection
    [Expand]Customization
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[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
[Expand]Reporting
[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

How to: Group Items in a Pivot Table

Grouping can help you to get a clearer view of data and show only data you want to analyze.

Expanded Group a Pivot Table by Date

Start with a raw data table that shows sales figures for a customer and a product on a certain date.

Create a pivot table that shows the total sum of all sales for each customer on each date.

To group the sales amount by month and quarter, perform the following steps.
  • Right click on left column of the pivot table (containing the dates) and select Group....
  • The Grouping dialog is invoked. Select Months and Quarters and click OK.

  • The result is shown in the picture below.

You can also group the pivot table in code, using the PivotField.GroupItems method with the combination of PivotFieldGroupByType.Quarters and PivotFieldGroupByType.Months values passed as a single parameter.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T298650.

This code snippet groups the field by month and quarter.

Expanded Group a Pivot Table by Range

Start with a raw data table that shows sales figures for a product.

Create a pivot table that shows the number of sales for each product.

To group the sales amounts by thousands, perform the following steps.

  • Right click on top row of the pivot table (containing the sales amounts) and select Group...
  • The Grouping dialog is invoked. Type in start value, end value, interval and click OK.

  • The result is shown in the picture below.

You can also group the pivot table in code, using the PivotField.GroupItems method with the PivotFieldGroupByType.NumericRanges parameter specifying the smallest and largest number to group the field and an interval for each group.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T298650.

Expanded Group Selected Items

You can select specific items and group them.

In the pivot table shown at the picture below, select the first three items - Arizona, California and Colorado.

Right click and select Group.... Press F2 to change the name of the group from Group to West. Press Enter to finish. The result is as follows.

You can also group the pivot table in code, using the PivotField.GroupItems method with a list of item indices (0, 1, 2) passed as a parameter.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T298650.

Expanded Ungroup Data

To ungroup the values in a pivot table, do the following.

  • Right click on the row or column of the pivot table containing the grouped values.
  • Select the option Ungroup....

To ungroup a grouped field in code, use the PivotField.UngroupItems method without parameters.

Use the PivotField.UngroupItems method with a name of the group as a parameter to ungroup only that group of items, as illustrated in the following code snippet.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T298650.

The following code creates two groupings with different items and subsequently ungroups the first group of items.

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