Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

PivotCalculatedFieldCollection.Add(String) Method

Creates a new calculated field and appends it to the collection.

Namespace: DevExpress.Spreadsheet

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

Declaration

PivotField Add(
    string formula
)

Parameters

Name Type Description
formula String

The formula used to calculate field values.

Returns

Type Description
PivotField

The newly created calculated field.

Remarks

Use the Add method to add a calculated field to the PivotTable report. The default name (Field1, Field2, …) is assigned to the new field. Use the PivotField.Name property to rename the field.

A formula for the calculated field should conform to the common syntax rules and contain only supported elements:

  • In the formula, you can use constants and refer to other fields in the PivotTable report. Calculations are performed on the sum of the underlying data for any field in the formula. When you reference a field in your formula, you can enclose the field name in apostrophes or omit them.
  • You cannot create formulas that use a cell reference, defined name, circular references, or arrays.
  • You cannot use worksheet functions that require cell references or defined names as arguments.
  • The formula cannot refer to the PivotTable’s subtotals, totals, and Grand Total value.
  • The formula should use culture-dependent separators. Use the DocumentOptions.Culture property to specify the workbook culture.

After the calculated field is created, call the PivotTable.DataFields.Add method to add the field to the PivotTable’s data area.

Refer to the following topic for more information on how to create and modify calculated fields: How to: Create a Calculated Field.

See Also