Back to Devexpress

OLAPExpressionBinding Class

aspnet-devexpress-dot-web-dot-aspxpivotgrid-09590d71.md

latest3.5 KB
Original Source

OLAPExpressionBinding Class

Allows you to use an expression to evaluate values for a Pivot Grid’s field in OLAP mode.

Namespace : DevExpress.Web.ASPxPivotGrid

Assembly : DevExpress.Web.ASPxPivotGrid.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class OLAPExpressionBinding :
    OLAPExpressionBindingBase
vb
Public Class OLAPExpressionBinding
    Inherits OLAPExpressionBindingBase

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).

Follow the steps below to create a calculated field in OLAP mode.

  1. Create an OLAPExpressionBinding instance and pass the expression to its constructor as a parameter. You can also use the object’s OLAPExpressionBindingBase.Expression property to specify the expression.
  2. Assign the created object to the PivotGridFieldBase.DataBinding property.

The following code snippet shows how to bind the fieldSales field to the MDX expression:

csharp
using System;
using DevExpress.XtraPivotGrid;
using DevExpress.Web.ASPxPivotGrid;
//...
PivotGridField fieldSales = new PivotGridField();
fieldSales.Caption = "Cleared Amount";
fieldSales.Area = PivotArea.DataArea;
fieldSales.DataBinding = new OLAPExpressionBinding("[Measures].[Internet Sales Amount] * 0.87");
ASPxPivotGrid1.Fields.Add(fieldSales);
vb
Imports System
Imports DevExpress.XtraPivotGrid
Imports DevExpress.Web.ASPxPivotGrid
'...
Private fieldSales As New PivotGridField()
fieldSales.Caption = "Cleared Amount"
fieldSales.Area = PivotArea.DataArea
fieldSales.DataBinding = New OLAPExpressionBinding("[Measures].[Internet Sales Amount] * 0.87")
ASPxPivotGrid1.Fields.Add(fieldSales)

Note

Use ExpressionDataBinding in Server and Optimized modes.

Implements

INotifyPropertyChanged

DevExpress.XtraPivotGrid.IDesignerContextProvider

Inheritance

Object DataBindingBase OLAPExpressionBindingBase OLAPExpressionBinding

See Also

OLAPExpressionBinding Members

Bind Pivot Grid Fields to Calculated Expressions

DevExpress.Web.ASPxPivotGrid Namespace