Back to Devexpress

Subtotal Dialog

wpf-118892-controls-and-libraries-spreadsheet-visual-elements-dialogs-subtotal-dialog.md

latest4.1 KB
Original Source

Subtotal Dialog

  • Apr 16, 2025
  • 3 minutes to read

The Subtotal dialog allows end-users to automatically group related data in a worksheet and add summary rows to each group using the SUBTOTAL function.

Add the Outline ribbon group to enable the Subtotal button, which invokes the target dialog. Refer to the Create a Simple Spreadsheet Application topic for details on how to provide a Ribbon UI for the SpreadsheetControl.

Insert Subtotals

Before subtotaling, make sure that the target range meets the following requirements:

  • It contains similar data in each column;
  • It has column headings in the first row;
  • It does not include blank rows or columns.

The Subtotal dialog allows end-users to set the following subtotal options:

OptionDescription
At each change inSpecifies a column heading by which the data should be grouped. Each time a value in this column changes, a new subtotal row is inserted. Sort your data by the target column to ensure that the same column values will be in one group.
Use functionSets the function to calculate subtotals. Eleven functions are available: Sum, Count, Average, Max, Min, Product, Product Numbers, StdDev, StdDevp, Var or Varp.
Add subtotals toSpecifies column(s) for which the SUBTOTAL function should be calculated.
Replace current subtotalsSets whether existing subtotals should be replaced with the recently specified ones. Clear this check box if you wish to create more than one level of subtotals (for example, to insert subtotals for the inner groups using different summary functions).
Page break between groupsLocates each group on a new page. It can be useful if your groups contain many detail rows and you wish to separate them while printing.
Summary below dataSets whether a summary row should be displayed below detail rows in each group. Without this option specified, the summary row will be displayed at the top of the group.

As a result, the SUBTOTAL function appears as in the image below:

The number (1-11 or 101-111) specifies a function to use for the subtotal. 1-11 includes hidden rows, while 101-111 excludes them. End-users can change this argument in the cell or formula bar. The table below lists functions and corresponding numbers.

FunctionNumber (includes hidden values)Number (ignores hidden values)
AVERAGE1101
COUNT2102
COUNTA3103
MAX4104
MIN5105
PRODUCT6106
STDEV7107
STDEVP8108
SUM9109
VAR10110
VARP11111

Tip

To programmatically specify subtotals for a cell range, use the Worksheet.Subtotal or RangeExtensions.Subtotal method. Refer to the How to: Insert Subtotals in a Data Range topic for details.

See Also

Group Data in the Spreadsheet Control

Spreadsheet Examples