Skip to main content

Summary Display Types

  • 4 minutes to read

Summaries in cells are calculated according to the PivotGridFieldBase.SummaryType property of data field.

Pivot Grid can show how cell values correlate to summary values in other cells instead of displaying raw summary results. For instance, the Pivot Grid allows you to display the percentage of totals and grand totals, or the absolute or percentage difference between current and preceding cells.

Optimized Mode

You can implement the summary display type functionality through window calculations in Optimized mode. For this use the following classes:

Refer to the following topic for more information: Bind Pivot Grid Fields to Window Calculations.

You can also implement custom summaries to build an expression that executes complex calculations for a Pivot Grid field.

Example

This example shows how to use different summary display types.

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

Change SummaryDisplayMode options

<dx:ASPxComboBox ID="ddlSummaryDisplayType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSummaryDisplayType_SelectedIndexChanged"
    width="195" />
<!-- ... -->
<dx:ASPxPivotGrid ID="pivotGrid" runat="server" width="100%">
    <OptionsView ShowFilterHeaders="false" HorizontalScrollBarMode="Auto" />
    <OptionsData DataProcessingEngine="Optimized" />
    <OptionsFilter NativeCheckBoxes="False" />
</dx:ASPxPivotGrid>
        protected void ddlSummaryDisplayType_SelectedIndexChanged(object sender, EventArgs e) {
            SetSelectedSummaryDisplayType();
        }
        void SetSelectedSummaryDisplayType() {
            if(SummaryDisplayTypeDataField == null)
                return;
            DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
            switch(ddlSummaryDisplayType.SelectedItem.Text) {
                case "AbsoluteVariation":
                    SummaryDisplayTypeDataField.DataBinding = new DifferenceBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.RowValue,
                        CalculationDirection.DownThenAcross,
                        DifferenceTarget.Previous,
                        DifferenceType.Absolute);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "n0";
                    break;
                case "PercentVariation":
                    SummaryDisplayTypeDataField.DataBinding = new DifferenceBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.RowValue,
                        CalculationDirection.DownThenAcross,
                        DifferenceTarget.Previous,
                        DifferenceType.Percentage);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
                    break;
                case "PercentOfColumn":
                    SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.ColumnValueAndRowParentValue);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
                    break;
                case "PercentOfRow":
                    SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.RowValueAndColumnParentValue);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
                    break;
                case "PercentOfColumnGrandTotal":
                    SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.ColumnValue);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";

                    break;
                case "PercentOfRowGrandTotal":
                    SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.RowValue);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
                    break;
                case "PercentOfGrandTotal":
                    SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.None);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
                    break;
                case "RankInColumnLargestToSmallest":
                    SummaryDisplayTypeDataField.DataBinding = new RankBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.ColumnValue,
                        RankType.Dense, PivotSortOrder.Descending);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "n0";
                    break;
                case "RankInColumnSmallestToLargest":
                    SummaryDisplayTypeDataField.DataBinding = new RankBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.ColumnValue,
                        RankType.Dense, PivotSortOrder.Ascending);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "n0";
                    break;
                case "RankInRowLargestToSmallest":
                    SummaryDisplayTypeDataField.DataBinding = new RankBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.RowValue,
                        RankType.Dense, PivotSortOrder.Descending);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "n0";
                    break;
                case "RankInRowSmallestToLargest":
                    SummaryDisplayTypeDataField.DataBinding = new RankBinding(
                        sourceBinding,
                        CalculationPartitioningCriteria.ColumnValue,
                        RankType.Dense, PivotSortOrder.Ascending);
                    SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    SummaryDisplayTypeDataField.CellFormat.FormatString = "n0";
                    break;
            }
            SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
        }
    }
}

Legacy and LegacyOptimized Modes

A data field’s PivotGridFieldBase.SummaryType property allows you to choose one of the predefined summary display types. The default value of this property (FieldSummaryDisplayType.Default) indicates that summary values are displayed as is.

More Documentation

See the following topics for more information about predefined summary display types: