Skip to main content
A newer version of this page is available. .
Tag

PivotGridFieldBase.OLAPDimensionCaption Property

Specifies the OLAP dimension’s caption displayed in the Customization form’s field list.

Namespace: DevExpress.XtraPivotGrid

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

Declaration

[DefaultValue(null)]
public string OLAPDimensionCaption { get; set; }

Property Value

Type Default Description
String *null*

A string that is the OLAP dimension caption displayed in the Customization form.

Remarks

You can group dimensions in the Customization form’s field list by setting the OLAPDimensionCaption to the same value, as illustrated in the picture below. The City and Country fields have the OLAPDimensionCaption property set to Location.

OLAPDimensionCaption

Example

If you have a cube on the OLAP server (Microsoft Analysis Services), you can view its data using the Pivot Grid. This example demonstrates how to specify connection settings and create fields that represent measures and dimensions of the cube.

To bind the Pivot Grid control to an OLAP cube, follow the steps below.

  • Set ADOMD as data provider using the PivotGridControl.OLAPDataProvider property.
  • Specify connection settings using the PivotGridControl.OLAPConnectionString property. The following connection string is used in this example:

    Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;

  • Create fields for measures and dimension in the bound OLAP cube. Use the PivotGridControl.RetrieveFields method overload that create fields, moves them to the specified area and makes them hidden. Another option is creating a new field and specifying its PivotGridFieldBase.OLAPExpression property.
  • Place the fields to the Pivot Grid Control areas as required and make them visible by setting the PivotGridFieldBase.Visible property.

Use the invoked Customization Form to arrange fields.

Note

The complete sample project How to connect a Pivot Grid to an OLAP datasource is available at the DevExpress Examples repository on GitHub.

using DevExpress.XtraPivotGrid;
using DevExpress.XtraPivotGrid.Customization;

namespace WinOlapRetrieveFieldsExample
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            // Specify the OLAP connection settings.
            pivotGridControl1.OLAPDataProvider = OLAPDataProvider.Adomd;
            pivotGridControl1.OLAPConnectionString =
                @"Provider=MSOLAP;
                Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll; 
                Initial catalog=Adventure Works DW Standard Edition;
                Cube name=Adventure Works;
                Query Timeout=100;";

            // Set the Customization Forms style.
            pivotGridControl1.OptionsCustomization.CustomizationFormStyle = CustomizationFormStyle.Excel2007;
            // Invoke the Customization Form.
            pivotGridControl1.FieldsCustomization();
        }

        private void btnRetrieveFields_Click(object sender, System.EventArgs e)
        {
            // Retrieve fields.
            pivotGridControl1.RetrieveFields(PivotArea.ColumnArea, false);

            // Add fields from the Field List to the specified area to create a report.
            pivotGridControl1.BeginUpdate();
            pivotGridControl1.Fields["[Customer].[Country].[Country]"].Area = PivotArea.RowArea;
            pivotGridControl1.Fields["[Customer].[Country].[Country]"].OLAPDimensionCaption = "TEST";
            pivotGridControl1.Fields["[Customer].[Country].[Country]"].Visible = true;
            pivotGridControl1.Fields["[Customer].[City].[City]"].Area = PivotArea.RowArea;
            pivotGridControl1.Fields["[Customer].[City].[City]"].Visible = true;
            pivotGridControl1.Fields["[Date].[Fiscal].[Fiscal Year]"].Area = PivotArea.ColumnArea;
            pivotGridControl1.Fields["[Date].[Fiscal].[Fiscal Year]"].Visible = true;
            pivotGridControl1.Fields["[Measures].[Internet Sales Amount]"].Visible = true;
            pivotGridControl1.EndUpdate();

            // Resize columns automatically.
            pivotGridControl1.BestFit();

            // Invoke the Customization Form.
            pivotGridControl1.FieldsCustomization();
        }

        private void btnCreateFields_Click(object sender, System.EventArgs e)
        {
            pivotGridControl1.BeginUpdate();
            pivotGridControl1.Fields.Clear();

            // Create a field, specify a query expression to obtain data and a caption to display it in the Customization form.
            PivotGridFieldBase fieldCountry = pivotGridControl1.Fields.Add("Country", PivotArea.RowArea);
            fieldCountry.OLAPExpression = "[Customer].[Country].[Country]";
            fieldCountry.OLAPDimensionCaption = "Location";

            PivotGridFieldBase fieldCity = pivotGridControl1.Fields.Add("City", PivotArea.RowArea);
            fieldCity.OLAPExpression = "[Customer].[City].[City]";
            fieldCity.OLAPDimensionCaption = "Location";

            PivotGridField measureField = new PivotGridField() { Caption = "Cleared Amount", Area = PivotArea.DataArea };
            measureField.OLAPExpression = "[Measures].[Internet Sales Amount] * 0.87";
            measureField.OLAPDimensionCaption = "Sales";
            pivotGridControl1.Fields.Add(measureField);

            PivotGridFieldBase fieldTop10 = pivotGridControl1.Fields.Add("Top10", PivotArea.ColumnArea);
            fieldTop10.OLAPExpression = "TOPCOUNT([Date].[Date].[Date].MEMBERS, 10, [Measures].[Internet Sales Amount])";
            fieldTop10.OLAPDimensionCaption = "Top";
            fieldTop10.Visible = false;;

            pivotGridControl1.EndUpdate();

            // Invoke the Customization Form.
            pivotGridControl1.FieldsCustomization();
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the OLAPDimensionCaption property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also