windowsforms-404009-controls-and-libraries-pivot-grid-binding-to-data-olap-mode-bind-pivot-grid-fields-to-calculated-expressions.md
This topic describes how to use the Binding API to create calculated fields in OLAP mode.
Calculated fields display the result of calculated expressions. Each calculated field has a binding expression that can be a formula or an aggregate function. The expression allows you to not only obtain values from a field in the data source, but specify exactly how to calculate the data (for example, aggregate it).
Follow the steps below to create a calculated field in the Pivot Grid:
Add a new data field in any of the following ways:
Set the field’s PivotGridFieldBase.DataBinding property to OLAP Expression.
Specify the MDX expression.
Note
You cannot use the Expression Editor dialog in OLAP mode.
OLAP mode supports OLAPExpressionBinding.
Follow the steps below to create a calculated field in OLAP mode:
The following code snippet shows how to bind measureField to the MDX expression:
PivotGridField measureField = new PivotGridField() { Caption = "Cleared Amount",
Area = PivotArea.DataArea };
measureField.DataBinding = new OLAPExpressionBinding("[Measures].[Internet Sales Amount] * 0.87");
measureField.Name = "fieldInternetSalesAmount";
pivotGridControl1.Fields.Add(measureField);
Dim measureField As PivotGridField = New PivotGridField() With {.Caption = "Cleared Amount", .Area = PivotArea.DataArea}
measureField.DataBinding = New OLAPExpressionBinding("[Measures].[Internet Sales Amount] * 0.87")
measureField.Name = "fieldInternetSalesAmount"
pivotGridControl1.Fields.Add(measureField)