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.v20.2.Core.dll

Declaration

PivotField Add(
    string formula
)

Parameters

Name Type Description
formula String

A String value that specifies the formula for the field.

Returns

Type Description
PivotField

A PivotField object that specifies the newly created calculated field.

Remarks

Use the Add method to add a calculated field to the PivotTable report. The default name (Field1, Field2, etc.) will be automatically assigned to the calculated field. To rename the field, use the PivotField.Name property.

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. The calculation will be performed on the sum of the underlying data for any fields in the formula. When you reference a field in your formula, you can enclose its name in apostrophes or omit them.
  • You cannot create formulas that use a cell reference, defined name, circular references and 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.

After the calculated field is created, add it to the PivotTable’s data area using the PivotDataFieldCollection.Add method of the PivotTable.DataFields collection.

For examples on how to create and modify calculated fields, refer to the How to: Create a Calculated Field article.

See Also