Percentage Types
- 5 minutes to read
Percentage summary display types are designed to show cell values as a percentage of the Total and Grand Total values in data cells. To employ these types, use PercentOfTotalBinding in Optimized mode.
The following percentage types are available:
Percent of Column
The percentage of the Column Total value is displayed in a cell.
Example
The following code snippet shows how to calculate the percentage of column total 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;
// ...
}
field.Tag = newValue;
(field.Parent as PivotGridControl).ReloadData();
}
Note
Set PivotGridField.SummaryDisplayType to FieldSummaryDisplayType.PercentOfColumn in Legacy and LegacyOptimized modes.
Percent of Column Grand Total
The percentage of the Column Grand Total value is displayed in a cell.
Example
The following code snippet shows how to calculate the percentage of column grand total 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.PercentOfColumnGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.ColumnValue);
break;
// ...
}
field.Tag = newValue;
(field.Parent as PivotGridControl).ReloadData();
}
Note
Set PivotGridField.SummaryDisplayType to FieldSummaryDisplayType.PercentOfColumnGrandTotal in Legacy and LegacyOptimized modes.
Percent of Row
The percentage of the Row Total value is displayed in a cell.
Example
The following code snippet shows how to calculate the percentage of row total 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.PercentOfRow:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValueAndColumnParentValue);
break;
// ...
}
field.Tag = newValue;
(field.Parent as PivotGridControl).ReloadData();
}
Note
Set PivotGridField.SummaryDisplayType to FieldSummaryDisplayType.PercentOfRow in Legacy and LegacyOptimized modes.
Percent of Row Grand Total
The percentage of the Row Grand Total value is displayed in a cell.
Example
The following code snippet shows how to calculate the percentage of row total 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.PercentOfRowGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValue);
break;
// ...
}
field.Tag = newValue;
(field.Parent as PivotGridControl).ReloadData();
}
Note
Set PivotGridField.SummaryDisplayType to FieldSummaryDisplayType.PercentOfRowGrandTotal in Legacy and LegacyOptimized modes.
Percent of Grand Total
The percentage of the Grand Total value is displayed in a cell.
Example
The following code snippet shows how to calculate the percentage of grand total 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.PercentOfGrandTotal:
field.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.None);
break;
// ...
}
field.Tag = newValue;
(field.Parent as PivotGridControl).ReloadData();
}
Note
Set PivotGridField.SummaryDisplayType to FieldSummaryDisplayType.PercentOfGrandTotal in Legacy and LegacyOptimized modes.