# Subtotals

## Content



FlexPivot control allows users to display subtotals using various aggregate functions such as Sum, Count, Average, etc.

![](https://cdn.mescius.io/document-site-files/images/031bb4c0-b90c-4b86-8ec8-de35ea515f84/images/pivot-subtotals.png)

This can either be done at runtime through the **Field Settings** dialog, or in code as described in the following sections.

## Calculate Subtotals at Runtime

1.  Right-click the field in the Values area of the FlexPivotPanel control and select Field Settings option.
2.  Click the **Subtotals** tab and select the type of aggregate function you want to apply.<br />![Displaying Fields Setting Dialog](https://cdn.mescius.io/document-site-files/images/031bb4c0-b90c-4b86-8ec8-de35ea515f84/images/fields-settings-subtotal-tab.png)
3.  Click **OK** and observe the change in the values.

## Calculate Subtotals Programmatically

You can use the Subtotal property to calculate subtotals programmatically, as shown in the following code. This implementation uses the sample created in [Quick Start](/componentone/docs/wpf/online-flexpivot5/quick-start) topic.

```csharp
//Apply average subtotal to ExtendedPrice column
fpEngine.Fields["ExtendedPrice"].Subtotal = Subtotal.Average;
```