Summary Display Types
- 2 minutes to read
Summaries in cells are calculated according to the SummaryType property of data fields.
PivotGridControl 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
The following code snippet shows how to calculate different types of a percentage of all values for the Number field:
void ItemClick(object sender, EventArgs e) {
// ...
PivotGridField field = item.Tag as PivotGridField;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding("Number");
PivotSummaryDisplayType newValue = (PivotSummaryDisplayType)Enum.Parse(typeof(PivotSummaryDisplayType), item.Caption);
switch(newValue) {
// ...
case PivotSummaryDisplayType.PercentOfColumn:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.ColumnValueAndRowParentValue);
break;
case PivotSummaryDisplayType.PercentOfRow:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValueAndColumnParentValue);
break;
case PivotSummaryDisplayType.PercentOfColumnGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.ColumnValue);
break;
case PivotSummaryDisplayType.PercentOfRowGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValue);
break;
case PivotSummaryDisplayType.PercentOfGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.None);
break;
// ...
default:
field.DataBinding = sourceBinding;
break;
}
field.Tag = newValue;
}
Legacy, LegacyOptimized, and OLAP Modes
A data field’s PivotGridFieldBase.SummaryDisplayType property allows you to choose one of the predefined summary display types. The default value of this property (PivotSummaryDisplayType.Default) indicates that summary values are displayed as is.
More Documentation
See the following topics for more information about predefined summary display types: