Skip to main content
A newer version of this page is available. .

PivotGridControl.CustomSummary Event

Allows you to calculate summary values manually.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v20.2.dll


public event PivotCustomSummaryEventHandler CustomSummary

Event Data

The CustomSummary event's data class is PivotCustomSummaryEventArgs. The following properties provide information specific to this event:

Property Description
ColumnField Gets the column field that corresponds to the current cell.
ColumnFieldValue Gets the value of the column field which corresponds to the current cell.
CustomValue Gets or sets a custom summary value.
DataField Gets the data field against which the summary is calculated.
FieldName Gets the name of the data field against which the summary is calculated.
RowField Gets the row field that corresponds to the current cell.
RowFieldValue Gets the value of the row field which corresponds to the current cell.
SummaryValue Gets an object which contains the values of the predefined summaries that are calculated for the current cell.
ThreadSafeColumnField Gets the column field that corresponds to the current cell. Provides read-only access to field settings.
ThreadSafeDataField Gets the data field against which the summary is calculated. Provides read-only access to field settings.
ThreadSafeRowField Gets the row field that corresponds to the current cell.

The event data class exposes the following methods:

Method Description
CreateDrillDownDataSource() Returns a list of the records which are associated with the cell currently being processed.


The CustomSummary event is raised when the PivotGridControl calculates its data for display. The CustomSummary event occurs for each cell that displays the value of the field whose PivotGridField.SummaryType property is set to FieldSummaryType.Custom.

In the event handler you can use the PivotCustomSummaryEventArgs.CreateDrillDownDataSource method to get a list of the records that is the data summarized in the current cell. You can process the data to calculate a custom summary and assign the result to the PivotCustomSummaryEventArgs.CustomValue property.

The PivotGridControl calculates all the predefined summaries (Average, Min, Max, Sum, etc) for each cell. You can access the calculated values using the PivotCustomSummaryEventArgs.SummaryValue property and use them in custom summary calculations.

The CustomSummary event occurs when the control layout is not ready yet. It means that other cells, columns and rows are not accessible.


To include other cells in a custom cell value calculation, handle the PivotGridControl.CustomCellValue event.


The CustomSummary event is not supported in server and OLAP mode.


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

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


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

<dx:ThemedWindow x:Class="DXPivotGrid_CustomSummary.MainWindow" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800" 

        <dxpg:PivotGridControl CustomSummary="pivotGridControl1_CustomSummary" Loaded="PivotGridControl1_Loaded" Name="pivotGridControl1">
                <dxpg:PivotGridField Name="fieldCategoryName" FieldName="CategoryName" Area="RowArea" AreaIndex="0" Caption="Category Name" />
                <dxpg:PivotGridField Name="fieldProductName" FieldName="ProductName" Area="RowArea" AreaIndex="1" Caption="Product Name" />
                <dxpg:PivotGridField Name="fieldOrderDate" FieldName="OrderDate" Area="ColumnArea" AreaIndex="0" Caption="OrderDate" GroupInterval="DateYear" />
                <dxpg:PivotGridField Name="fieldQuantity" FieldName="Quantity" Area="DataArea" AreaIndex="0" Caption="Quantity" />
                <dxpg:PivotGridField Name="fieldQuantityDistinctCount" FieldName="Quantity" Area="DataArea" AreaIndex="1" Caption="Count Distinct" SummaryType="Custom" />

See Also