Skip to main content

PivotGridFieldBase.UnboundExpression Property

Gets or sets an expression used to evaluate the unbound field’s value.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v24.2.Core.dll

Declaration

[DefaultValue("")]
public string UnboundExpression { get; set; }

Property Value

Type Default Description
String String.Empty

A String that specifies an expression used to evaluate the field.

Remarks

Note

This member is not supported in Optimized, OLAP, and Server modes. Use ExpressionDataBinding/OlAPExpressionBinding instead.

Tip

An unbound field is a field whose PivotGridFieldBase.UnboundType property is set to the type other than UnboundColumnType.Bound. Refer to the Unbound Fields document for more information.

A valid expression is a string based on a syntax described in the Pivot Grid Expression Syntax document. To refer to a Pivot Grid field in an expression, use the name obtained from the PivotGridField.ExpressionFieldName property.

An expression’s result is dependent on the calculation mode, specified using the PivotGridFieldBase.UnboundExpressionMode property. It determines whether an expression is calculated for each underlying data source records and values are summarized, or an expression uses summary values.

Note

Hidden fields and fields located in the Filter Area cannot be used in summary calculations. An expression containing these fields in the UseSummaryValues or UseAggregateFunctions mode the returns the ‘Error’ value.

The UnboundExpression property fires the FieldUnboundExpressionChanged event when changed.

Example

The following code snippet demonstrates how to create an unbound field in code and use the PivotGridField.UnboundExpression property to supply data. In this example, extended price values are calculated as follows:

[Quantity] * [UnitPrice] * (1 - [Discount]).

Pivot Grid field names are obtained using the PivotGridFieldBase.ExpressionFieldName property.

PivotGridField fieldExtendedPrice = new PivotGridField() { Caption = "Extended Price", Area = PivotArea.DataArea };
fieldExtendedPrice.UnboundFieldName = "fieldExtendedPrice";
fieldExtendedPrice.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
fieldExtendedPrice.UnboundExpression = string.Format("[{0}] * [{1}] * (1 - [{2}])", 
    fieldQuantity.ExpressionFieldName, fieldUnitPrice.ExpressionFieldName, fieldDiscount.ExpressionFieldName);
pivotGridControl1.Fields.Add(fieldExtendedPrice);
}
See Also