FlexPivot Cube / Display KPI in OLAP
Display KPI in OLAP

An OLAP (On-line Analytical Processing) Cube is a multi-dimensional database that performs instantaneous analysis and display of large chunks of data. The cube contains metrics of data such as KPI (Key Performance Indicator) information, which can be used to measure the progress of a business in meeting its goals. Being an excellent data processing tool, the FlexPivot control can automatically recognize the information in the OLAP Cube and display it in an appropriate format in its page.

The GIF below displays a report on the FlexPivotPage for the Internet Revenue/Sales KPI from the Adventure Works sample cube. Note how the KPI data is shown in the FlexPivotPage using the Value Fields.

OLAP_CubeDataAnalysis

For each KPI in the OLAP cube, there is a corresponding measure for its status and trend. The associated graphics of each KPI can be specified using the KpiGraphics enumeration. In the code below, a Combo Box is used to display the KpiGraphics enumeration values to alter the KPI graphics at runtime. The selected graphics can be applied to the KPI fields using the KpiField class of C1.PivotEngine.Internal namespace.

The code below illustrates how to add KPI Field data from OLAP Cube in the FlexPivotPage.

Partial Public Class Form1
    Inherits Form

    Private flexPivotPage1 As FlexPivotPage
    Private KpiGraphicsCombo As ComboBox

    Public Sub New()
        InitializeComponent()
        flexPivotPage1 = New FlexPivotPage()
        flexPivotPage1.Height = 500
        flexPivotPage1.Width = 800
        flexPivotPage1.Dock = DockStyle.Bottom
        Dim connectionString As String = "Data Source=http://ssrs.componentone.com/OLAP/msmdpump.dll;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional"
        Dim cubeName As String = "Adventure Works"
        flexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString)
        Dim fp = flexPivotPage1.PivotEngine
        fp.BeginUpdate()
        fp.ColumnFields.Add("Date.Fiscal Year")
        fp.RowFields.Add("Category")
        fp.ValueFields.Add("Internet Revenue Trend")
        fp.ValueFields.Add("Internet Revenue Status")
        fp.EndUpdate()
        Me.Controls.Add(flexPivotPage1)
        KpiGraphicsCombo = New ComboBox()
        KpiGraphicsCombo.Left = 160
        KpiGraphicsCombo.Top = 35
        KpiGraphicsCombo.DataSource = [Enum].GetValues(GetType(C1.PivotEngine.Internal.KpiGraphics))
        KpiGraphicsCombo.SelectedIndexChanged += AddressOf KpiGraphicsComboBox_SelectedIndexChanged
        Me.Controls.Add(KpiGraphicsCombo)
    End Sub

    Private Sub KpiGraphicsComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        Scan(flexPivotPage1.PivotEngine.Fields)
    End Sub

    Private Sub Scan(ByVal list As IEnumerable(Of PivotField))
        For Each field In list
            If TypeOf field Is KpiField Then (TryCast(field, KpiField)).KpiGraphics = CType([Enum].Parse(GetType(C1.PivotEngine.Internal.KpiGraphics), KpiGraphicsCombo.SelectedValue.ToString()), C1.PivotEngine.Internal.KpiGraphics)
            If TypeOf field Is CubeField Then Scan((TryCast(field, CubeField)).SubFields)
        Next
    End Sub
End Class