.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PivotField.SetSubtotal(PivotSubtotalFunctions) Method

Specifies the function(s) to calculate subtotals for the PivotTable field.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.1.Core.dll


void SetSubtotal(
    PivotSubtotalFunctions type


Name Type Description
type PivotSubtotalFunctions

The PivotSubtotalFunctions enumeration members specifying one or more functions used to calculate subtotals for the field.


Use the SetSubtotal method to change the default summary calculation or to show more than one type of subtotal for a given PivotField, currently shown as an outer row or column field in the report.

The following example demonstrates how to use multiple functions to subtotal the “Category” row field. To do this, combine the required PivotSubtotalFunctions enumeration values with a bitwise OR operator.

Dim worksheet As Worksheet = workbook.Worksheets("Report1")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access the pivot field by its name in the collection.
Dim field As PivotField = pivotTable.Fields("Category")
' Display multiple subtotals for the field.  
field.SetSubtotal(PivotSubtotalFunctions.Sum Or PivotSubtotalFunctions.Average)

To use the default function to calculate a subtotal for a particular outer field, use the field’s PivotField.SetSubtotalAutomatic method.

Use the PivotField.SubtotalType property to obtain the type of subtotal displayed for a PivotTable field. To get the function(s) used to calculated the field’s subtotals, use the PivotField.SubtotalFunctions property.

See Also