OlapExpressionBinding Class
Allows you to use an expression to evaluate values for a Pivot Grid’s field in OLAP mode.
Namespace: DevExpress.Xpf.PivotGrid
Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll
NuGet Package: DevExpress.Wpf.PivotGrid
Declaration
Remarks
Calculated fields display the result of calculated expressions. You can use a formula or an aggregate function as a binding expression for each calculated field. The expression allows you to not only obtain values from a field in the data source, but also specify exactly how to calculate the data (for example, aggregate it).
Note
Use ExpressionDataBinding in Server and Optimized modes.
Follow the steps below to create a calculated field in OLAP mode:
- Create an
OLAPExpressionBinding
instance and pass the expression in its constructor as a parameter. You can also use the object’s OLAPExpressionBindingBase.Expression property to specify the expression. - Assign the created object to the PivotGridField.DataBinding property.
The following code snippet shows how to bind fieldSales
to the MDX expression:
using System.Windows;
using DevExpress.Xpf.PivotGrid;
namespace HowToBindOLAP {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
// ...
PivotGridField fieldSales = new PivotGridField();
fieldSales.Caption = "Cleared Amount";
fieldSales.Area = FieldArea.DataArea;
fieldSales.DataBinding = new OlapExpressionBinding("[Measures].[Internet Sales Amount] * 0.87");
fieldSales.CellFormat = "c";
pivotGridControl1.Fields.Add(fieldSales);
}
}
}