Skip to main content

Summary Display Types

  • 3 minutes to read

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

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

View Example: PivotGrid for WPF - How to Change SummaryDisplayType in the Context Menu

The following code snippet shows how to calculate different types of a percentage of all values for the Value field:

static void itemClickEventHandler(object sender, ItemClickEventArgs e) {
    BarItem barItem = sender as BarItem;
    object[] barItemInfo = (object[])barItem.Tag;
    PivotGridField field = (PivotGridField)barItemInfo[0];
    FieldSummaryDisplayType newValue = (FieldSummaryDisplayType)barItemInfo[2];
    DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding("Value");
    switch(newValue){
    // ...
        case FieldSummaryDisplayType.PercentOfColumn:
            field.DataBinding = new PercentOfTotalBinding(
                sourceBinding,
                CalculationPartitioningCriteria.ColumnValueAndRowParentValue);
            break;
        case FieldSummaryDisplayType.PercentOfRow:
            field.DataBinding = new PercentOfTotalBinding(
                sourceBinding,
                CalculationPartitioningCriteria.RowValueAndColumnParentValue);
            break;
        case FieldSummaryDisplayType.PercentOfColumnGrandTotal:
            field.DataBinding = new PercentOfTotalBinding(
                sourceBinding,
                CalculationPartitioningCriteria.ColumnValue);
            break;
        case FieldSummaryDisplayType.PercentOfRowGrandTotal:
            field.DataBinding = new PercentOfTotalBinding(
                sourceBinding,
                CalculationPartitioningCriteria.RowValue);
            break;
        case FieldSummaryDisplayType.PercentOfGrandTotal:
            field.DataBinding = new PercentOfTotalBinding(
                sourceBinding,
                CalculationPartitioningCriteria.None);
            break;
            // ...
    }
    field.Tag = newValue;
    (field.Parent as PivotGridControl).ReloadData();
}
#endregion CommonMethods

Legacy and LegacyOptimized modes

A data field’s PivotGridField.SummaryDisplayType 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: