How to: Bind a Dashboard to an OLAP Cube using DashboardOlapDataSource

  • 2 minutes to read

The following example demonstrates how to bind the dashboard to the OLAP cube using DashboardOlapDataSource.

DashboardOlapDataSource allows you to establish a connection to the OLAP cube by specifying a connection string.

View Example

Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.ConnectionParameters

Namespace Dashboard_OlapDataProvider
    Partial Public Class Form1
        Inherits RibbonForm

        Public Sub New()

'            #Region "#OLAPDataSource"
            Dim olapParams As New OlapConnectionParameters()
            olapParams.ConnectionString = "provider=MSOLAP;" _
                                & ControlChars.CrLf & _
                                "data source=;" _
                                & ControlChars.CrLf & _
                                "initial catalog=Adventure Works DW Standard Edition;" _
                                & ControlChars.CrLf & _
                                "cube name=Adventure Works;"

            Dim olapDataSource As New DashboardOlapDataSource(olapParams)

'            #End Region ' #OLAPDataSource

        End Sub

        Private Sub InitializeDashboardItems()
            Dim olapDataSource As IDashboardDataSource = dashboardDesigner1.Dashboard.DataSources(0)

            Dim pivot As New PivotDashboardItem()
            pivot.DataSource = olapDataSource
            pivot.Values.Add(New Measure("[Measures].[Sales Amount]"))
            pivot.Columns.Add(New Dimension("[Sales Channel].[Sales Channel].[Sales Channel]"))
            pivot.Rows.AddRange(New Dimension("[Sales Territory].[Sales Territory].[Group]", 1), _
                                New Dimension("[Sales Territory].[Sales Territory].[Country]", 1), _
                                New Dimension("[Sales Territory].[Sales Territory].[Region]", 1))
            pivot.AutoExpandRowGroups = True

            Dim chart As New ChartDashboardItem()
            chart.DataSource = olapDataSource
            chart.Arguments.Add(New Dimension("[Sales Territory].[Sales Territory].[Country]"))
            chart.Panes.Add(New ChartPane())
            Dim salesAmountSeries As New SimpleSeries(SimpleSeriesType.Bar)
            salesAmountSeries.Value = New Measure("[Measures].[Sales Amount]")

            dashboardDesigner1.Dashboard.Items.AddRange(pivot, chart)
        End Sub
    End Class
End Namespace
See Also