# Binding to OLAP Data Sources | WPF Controls | DevExpress Documentation

The [PivotGridControl](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl) allows you to visualize data contained in a cube deployed on an OLAP server. In OLAP mode, the PivotGridControl delegates data management operations (such as summarization, grouping, etc.) to the server side. You can use OLAP binding mode to process large amounts of data. The following article describes recommendations related to OLAP data sources: [Pivot Grid Performance - OLAP](/CoreLibraries/403710/devexpress-pivot-grid-core-library/pivot-grid-performance#olap).

[Run Demo](dxdemo://Wpf/DXPivotGrid/MainDemo/OLAPBrowser) [Watch Video](https://www.youtube.com/watch?v=bmxXyl1UD0E)

## Requirements and Limitations

Refer to the following topic for information about requirements and limitations in OLAP mode: [Requirements and Limitations](/WPF/11783/controls-and-libraries/pivot-grid/binding-to-data/olap-data-source/requirements-and-limitations).

## Bind to an OLAP cube at Design Time

Important

You cannot bind the Pivot Grid to data at design time in .NET 5+ projects. Refer to the “Bind Pivot Grid to an OLAP cube in Code” section for information on how to populate the Pivot Grid with data in code.

Refer to the following tutorial for information on how to bind the Pivot Grid to an OLAP cube at design time in .NET Framework WPF applications: [Lesson 2 - Bind a Pivot Grid to an OLAP Cube](/WPF/10360/controls-and-libraries/pivot-grid/getting-started/NET-Framework/lesson-2-bind-a-pivot-grid-to-an-olap-cube). 

## Bind Pivot Grid to an OLAP cube in Code

### Bind Pivot Grid to an OLAP Cube

1. Use the [PivotGridControl.OlapDataProvider](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl.OlapDataProvider) property to specify the required data provider.
2. Specify connection settings to the server in the [PivotGridControl.OlapConnectionString](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl.OlapConnectionString) property. A sample connection string is shown below.

     `Provider=msolap;Data Source=localhost;Initial Catalog=Adventure Works DW;Cube Name=Adventure Works;Query Timeout=100;`

     Note that a valid connection string should contain the following parameters: **Provider**, **Data Source**, **Initial Catalog**, and **Cube Name**.

### Create Pivot Grid Fields

1. Create a [PivotGridField](/WPF/DevExpress.Xpf.PivotGrid.PivotGridField) object and add it to the [PivotGridControl.Fields](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl.Fields) collection.
2. Specify the field’s area and position within this area. For this, use the [PivotGridFieldBase.Area](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridFieldBase.Area) and [PivotGridField.AreaIndex](/WPF/DevExpress.Xpf.PivotGrid.PivotGridField.AreaIndex) properties. `AreaIndex` can be set only after the field is added to the control’s field collection.

Use the [PivotGridControl.GetFieldList](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl.GetFieldList) method to obtain a list of fields that are available in a bound data source, and the [PivotGridControl.RetrieveFields](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl.RetrieveFields.overloads) method to create [PivotGridField](/WPF/DevExpress.Xpf.PivotGrid.PivotGridField) objects for all available fields.

### Populate Pivot Grid Fields with Data

1. Create a `DataSourceColumnBinding` instance.
2. Specify the [DataSourceColumnBinding.ColumnName](/WPF/DevExpress.Xpf.PivotGrid.DataSourceColumnBinding.ColumnName) property. `ColumnName` must specify the full name of the bound measure or dimension.

    For dimensions, the full name is composed of a dimension name, followed by a hierarchy name, followed by the name of a level(s). All names should be wrapped within square brackets and separated from one another with the dot symbol. Example: “[Customer].[Customer Geography].[Country]”.

    For measures, the full name is composed of the “[Measures].” string followed by the measure name. Example: “[Measures].[Sales Amount]”.
3. Assign the `DataSourceColumnBinding` object to the [PivotGridField.DataBinding](/WPF/DevExpress.Xpf.PivotGrid.PivotGridField.DataBinding) property.

The following example demonstrates how to bind a [PivotGridControl](/WPF/DevExpress.Xpf.PivotGrid.PivotGridControl) to an MS OLAP cube.

[View Example](https://github.com/DevExpress-Examples/wpf-pivot-grid-bind-to-an-olap-cube-net6)

- MainWindow.xaml.vb
- MainWindow.xaml.cs

<section id="tabpanel_ka+pbHW3af_tabid-vbMainWindow-xaml-vb" role="tabpanel" data-tab="tabid-vbMainWindow-xaml-vb">
<pre><code data-code-links="{&quot;/ (System.Windows)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.windows&quot;,&quot;/ (DevExpress.Xpf.PivotGrid)(?:;|$)/&quot;:&quot;/WPF/DevExpress.Xpf.PivotGrid&quot;}" class="lang-vb">Imports System.Windows
Imports DevExpress.Xpf.PivotGrid

Namespace HowToBindOLAP
    &#39;&#39;&#39; &lt;summary&gt;
    &#39;&#39;&#39; Interaction logic for MainWindow.xaml
    &#39;&#39;&#39; &lt;/summary&gt;
    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            pivotGridControl1.OlapConnectionString = &quot;Provider=msolap;&quot; &amp; &quot;Data Source=https://demos.devexpress.com/Services/OLAP/msmdpump.dll;&quot; &amp; &quot;Initial Catalog=Adventure Works DW Standard Edition;&quot; &amp; &quot;Cube Name=Adventure Works;&quot;
            pivotGridControl1.BeginUpdate()
            &#39; Create Pivot Grid fields.
            Dim fieldMeasuresInternetSalesAmount As New PivotGridField()
            fieldMeasuresInternetSalesAmount.Caption = &quot;Internet Sales Amount&quot;
            fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea
            pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount)

            Dim fieldSales As New PivotGridField()
            fieldSales.Caption = &quot;Cleared Amount&quot;
            fieldSales.Area = FieldArea.DataArea
            fieldSales.CellFormat = &quot;c&quot;
            pivotGridControl1.Fields.Add(fieldSales)

            &#39; Populate fields with data.
            fieldMeasuresInternetSalesAmount.DataBinding = New DataSourceColumnBinding(&quot;[Measures].[Internet Sales Amount]&quot;)

            fieldSales.DataBinding = New OlapExpressionBinding(&quot;[Measures].[Internet Sales Amount] * 0.87&quot;)

            AddField(&quot;Country&quot;, FieldArea.RowArea, &quot;[Customer].[Country].[Country]&quot;, 0)
            AddField(&quot;Fiscal Year&quot;, FieldArea.ColumnArea, &quot;[Date].[Fiscal Year].[Fiscal Year]&quot;, 0)

            pivotGridControl1.EndUpdate()
        End Sub
        Private Function AddField(ByVal caption As String, ByVal area As FieldArea, ByVal fieldName As String, ByVal index As Integer) As PivotGridField
            Dim field As PivotGridField = pivotGridControl1.Fields.Add()
            field.Caption = caption
            field.Area = area
            If fieldName &lt;&gt; String.Empty Then
                field.DataBinding = New DataSourceColumnBinding(fieldName)
            End If
            field.AreaIndex = index
            Return field
        End Function
    End Class
End Namespace
</code></pre></section>
<section id="tabpanel_ka+pbHW3af_tabid-csharpMainWindow-xaml-cs" role="tabpanel" data-tab="tabid-csharpMainWindow-xaml-cs" aria-hidden="true" hidden="hidden">
<pre><code data-code-links="{&quot;/ (DevExpress.Xpf.PivotGrid)(?:;|$)/&quot;:&quot;/WPF/DevExpress.Xpf.PivotGrid&quot;,&quot;/ (System.Windows)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.windows&quot;}" class="lang-csharp">using DevExpress.Xpf.PivotGrid;
using System.Windows;

namespace HowToBindOLAP {
    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e) {
            pivotGridControl1.OlapConnectionString = &quot;Provider=msolap;&quot; +
                &quot;Data Source=https://demos.devexpress.com/Services/OLAP/msmdpump.dll;&quot; +
                &quot;Initial Catalog=Adventure Works DW Standard Edition;&quot; +
                &quot;Cube Name=Adventure Works;&quot;;
            pivotGridControl1.BeginUpdate();

            // Create Pivot Grid fields.
            PivotGridField fieldMeasuresInternetSalesAmount =
                new PivotGridField();
            fieldMeasuresInternetSalesAmount.Caption = &quot;Internet Sales Amount&quot;;
            fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea;
            pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount);

            PivotGridField fieldSales = new PivotGridField();
            fieldSales.Caption = &quot;Cleared Amount&quot;;
            fieldSales.Area = FieldArea.DataArea;
            fieldSales.CellFormat = &quot;c&quot;;
            pivotGridControl1.Fields.Add(fieldSales);

            // Populate fields with data.
            fieldMeasuresInternetSalesAmount.DataBinding =
                new DataSourceColumnBinding(&quot;[Measures].[Internet Sales Amount]&quot;);

            fieldSales.DataBinding =
                new OlapExpressionBinding(&quot;[Measures].[Internet Sales Amount] * 0.87&quot;);

            AddField(&quot;Country&quot;, FieldArea.RowArea, &quot;[Customer].[Country].[Country]&quot;, 0);
            AddField(&quot;Fiscal Year&quot;, FieldArea.ColumnArea, &quot;[Date].[Fiscal Year].[Fiscal Year]&quot;, 0);

            pivotGridControl1.EndUpdate();
        }
        // Add fields to the Pivot Grid and bind them to data.
        private PivotGridField AddField(string caption, FieldArea area, string fieldName, int index) {
            PivotGridField field = pivotGridControl1.Fields.Add();
            field.Caption = caption;
            field.Area = area;
            if (fieldName != string.Empty)
                field.DataBinding = new DataSourceColumnBinding(fieldName);
            field.AreaIndex = index;
            return field;
        }
    }
}
</code></pre></section>

- MainWindow.xaml

<section id="tabpanel_ka+pbHW3af-1_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;Window
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
        xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
        xmlns:local=&quot;clr-namespace:HowToBindOLAP&quot;
        xmlns:dxpg=&quot;http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid&quot; x:Class=&quot;HowToBindOLAP.MainWindow&quot;
        mc:Ignorable=&quot;d&quot;
        Title=&quot;MainWindow&quot; Height=&quot;450&quot; Width=&quot;800&quot; Loaded=&quot;Window_Loaded&quot;&gt;
    &lt;Grid&gt;
        &lt;dxpg:PivotGridControl Name=&quot;pivotGridControl1&quot;/&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;
</code></pre></section>

See Also

[Requirements and Limitations](/WPF/11783/controls-and-libraries/pivot-grid/binding-to-data/olap-data-source/requirements-and-limitations)