ComponentOne FlexPivot for WinForms
Data Blending Features / Specifying Subtotal Function
In This Topic
    Specifying Subtotal Function
    In This Topic

    FlexPivot control allows users to specify subtotals using various aggregate functions such as Sum, Count, Average, etc. This can either be done at runtime through the Field Settings dialog, or in code.

    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.

      Subtotals       

      Sum Gets the sum of a group
      Count Gets the number of values in a group.
      Average Gets the average of a group.
      Maximum Gets the maximum value in a group.
      Minimum Gets the minimum value in a group.
      First Gets the first value in a group.
      Last Gets the last value in a group.
      Variance Gets the sample variance of a group.
      Standard Deviation Gets the sample standard deviation of a group.
      Variance Population Gets the population variance of a group.
      Standard Deviation Population Gets the population standard deviation of a group.
    3. Click OK and observe the change in the values.

    In Code

    You can use the Subtotal property to specify subtotals in code.

    //formatting numeric data in code
    Dim field = fp.Fields("ExtendedPrice")
    field.Subtotal = C1.FlexPivot.Subtotal.Average
    
    // show average price
    var field = fp.Fields["ExtendedPrice"];
    field.Subtotal = C1.FlexPivot.Subtotal.Average;
    

    The FlexPivotPage class also provides the TotalsBeforeData property to determine whether row and column totals should be displayed before or after regular data rows and columns. The TotalsBeforeData property accepts Boolean values. If the value is set to true, total rows appear above data rows and total columns appear to the left of the regular data columns. By default, this property is set to false.