Skip to main content
Row

PivotField.SetSubtotal(PivotSubtotalFunctions) Method

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

Namespace: DevExpress.Spreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

void SetSubtotal(
    PivotSubtotalFunctions type
)

Parameters

Name Type Description
type PivotSubtotalFunctions

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

Remarks

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.

View Example

Worksheet worksheet = workbook.Worksheets["Report1"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Access the pivot field by its name in the collection.
PivotField field = pivotTable.Fields["Category"];
// Display multiple subtotals for the field.  
field.SetSubtotal(PivotSubtotalFunctions.Sum | 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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetSubtotal(PivotSubtotalFunctions) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also