[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Collapse]Data Shaping
    [Collapse]Summarization
     [Collapse]Summaries
       Summary Overview
       Automatic Summaries
       Custom Summaries
      [Expand]Summary Display Modes
       Accessing Summary Values
       Drill Down to the Underlying Data
      Totals
      Aggregation Levels
     Grouping
    [Expand]Sorting
    [Expand]Filtering
    [Expand]Data Formatting
   [Expand]Data Analysis
   [Expand]Layout
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Appearance
   [Expand]MVVM Enhancements
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Custom Summaries

Custom summaries allow you to manually calculate summaries using custom algorithms. This can be useful in the following instances:

  • calculating a custom summary function;
  • using multiple data fields in a summary calculation;
  • calculating a summary for individual records (for instance, for the records which match specific criteria).

To enable a custom summary calculations, set the data field's PivotGridField.SummaryType property to FieldSummaryType.Custom. Handle the PivotGridControl.CustomSummary event to implement a custom summary calculation algorithm. This event is fired for each summary cell that corresponds to this data field.

Note

When handling the PivotGridControl.CustomSummary event, use the PivotCustomSummaryEventArgs.CreateDrillDownDataSource method to obtain a subset of records in a datasource, which corresponds to the currently processed summary cell.

Note

Custom summaries calculated using the PivotGridControl.CustomSummary event are not supported in server mode.

Expanded Example: How to Calculate Custom Summaries

This example demonstrates how to use Custom Summaries to count distinct values (the number of orders with equal product quantities) and display the result in the pivot grid.

This example handles the PivotGridControl.CustomSummary event that occurs when the control calculates a summary for a field whose SummaryType (see PivotGridFieldBase.SummaryType) is PivotSummaryType. The event handler calls the PivotGridCustomSummaryEventArgsBase`1.CreateDrillDownDataSource method to retrieve the underlying data rows for the current cell, counts distinct values and returns the result to the PivotGridCustomSummaryEventArgsBase`1.CustomValue property.

Note

The complete sample project How to Create a Custom Summary Type to Display the Distinct Value Count is available in the DevExpress Examples repository.

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