Skip to main content

Custom Summaries

  • 2 minutes to read

This article describes how to create custom summaries in Optimized mode.

Note

Use the CustomSummary event to create custom summaries in Legacy or LegacyOptimized mode.

Custom Summaries Overview

Pivot Grid allows you to calculate common summary functions for data fields. You can create custom summaries to execute complex calculations.

Custom summaries can do the following:

  • Use predefined and custom aggregate functions to calculate summary values.
  • Involve multiple fields in a summary calculation.
  • Calculate a summary for records that match certain criteria.

Create a Custom Summary

Do the following to create a custom summary for a data field:

  1. Create a Pivot Grid field.
  2. Create an ExpressionDataBinding object, and specify a calculated summary expression in the object’s constructor.
  3. Assign the created ExpressionDataBinding object to the field’s DataBinding property.
  4. Add the field to the Data Area.

Refer to the following article for information on how to create calculated expressions: Bind Pivot Grid Fields to Calculated Expressions.

Example: How to Calculate a Custom Summary

This example demonstrates how to determine the value type when you calculate custom summary values.

View Example: Pivot Grid for Web Forms - How to Specify Custom Summary Values for Total, Grand Total, and Ordinary Cells

Custom Summary with IsTotal function

<dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" Theme="Metropolis" Width="800px" Height="500px" 
    OptionsView-VerticalScrollBarMode="Auto" OptionsView-VerticalScrollingMode="Standard"  
    ClientIDMode="AutoID" IsMaterialDesign="False" OptionsPager-Visible="False">
    <Fields>
        <dxwpg:PivotGridField ID="fieldRowGroup" Area="RowArea" AreaIndex="0">
            <DataBindingSerializable>
                <dxwpg:DataSourceColumnBinding ColumnName="RowGroup" />
            </DataBindingSerializable>
        </dxwpg:PivotGridField>
        <dxwpg:PivotGridField ID="fieldData" AreaIndex="0" Area="DataArea">
            <DataBindingSerializable>
                <dxwpg:ExpressionDataBinding Expression="iif(IsTotal([fieldColumnGroup]),'Grand Total',
                        IsTotal([fieldRowGroup]),'Grand Total',IsTotal([fieldColumn]),'Total',
                        IsTotal([fieldRow]),'Total',Sum([Data]))" />
            </DataBindingSerializable>
        </dxwpg:PivotGridField>
        <dxwpg:PivotGridField ID="fieldRow" Area="RowArea" AreaIndex="1">
            <DataBindingSerializable>
                <dxwpg:DataSourceColumnBinding ColumnName="Row" />
            </DataBindingSerializable>
        </dxwpg:PivotGridField>
        <dxwpg:PivotGridField ID="fieldColumnGroup" Area="ColumnArea" AreaIndex="0" >
            <DataBindingSerializable>
                <dxwpg:DataSourceColumnBinding ColumnName="ColumnGroup" />
            </DataBindingSerializable>
        </dxwpg:PivotGridField>
        <dxwpg:PivotGridField ID="fieldColumn" Area="ColumnArea" AreaIndex="1">
            <DataBindingSerializable>
                <dxwpg:DataSourceColumnBinding ColumnName="Column" />
            </DataBindingSerializable>
        </dxwpg:PivotGridField>
    </Fields>

<OptionsView VerticalScrollBarMode="Auto"></OptionsView>

<OptionsPager Visible="False"></OptionsPager>

<OptionsData DataProcessingEngine="Optimized"></OptionsData>
</dxwpg:ASPxPivotGrid>