ComponentOne FlexPivot for WinForms
FlexPivot Cube / Display KPI in OLAP
In This Topic
    Display KPI in OLAP
    In This Topic

    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.


    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 = New FlexPivotPage()
        Private KpiGraphicsComboBox As ComboBox = New ComboBox()
        Public Sub New()
            KpiGraphicsComboBox.DataSource = [Enum].GetValues(GetType(KpiGraphics))
            AddHandler KpiGraphicsComboBox.SelectedIndexChanged, AddressOf KpiGraphicsComboBox_SelectedIndexChanged
            flexPivotPage1.Height = 500
            flexPivotPage1.Width = 800
            Dim connectionString As String = "Data Source=;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional"
            Dim cubeName As String = "Adventure Works"
            flexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString)
            Dim fp = flexPivotPage1.FlexPivotEngine
            fp.ColumnFields.Add("Date.Fiscal Year")
            fp.ValueFields.Add("Internet Revenue Trend")
            fp.ValueFields.Add("Internet Revenue Status")
        End Sub
        Private Sub KpiGraphicsComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        End Sub
        Private Sub Scan(ByVal list As IEnumerable(Of C1FlexPivotField))
            For Each field In list
                If TypeOf field Is C1KpiField Then
                    TryCast(field, C1KpiField).KpiGraphics = CType([Enum].Parse(GetType(KpiGraphics), KpiGraphicsComboBox.SelectedValue.ToString()), KpiGraphics)
                End If
                If TypeOf field Is C1CubeField Then
                    Scan((TryCast(field, C1CubeField)).SubFields)
                End If
        End Sub
    End Class
    public Form1()
        //Initialize FlexPivotPage
        flexPivotPage1 = new FlexPivotPage();
        flexPivotPage1.Height = 500;
        flexPivotPage1.Width = 800;
        flexPivotPage1.Dock = DockStyle.Bottom;
        //Set up connection string
        string connectionString = @"Data Source=;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional";
        string cubeName = "Adventure Works";
        //Connect Cube Data to FlexPivotPage
        flexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString);
        //Show KPI Field data in the FlexPivotPage using ValueFields
        var fp = flexPivotPage1.FlexPivotEngine;
        fp.ColumnFields.Add("Date.Fiscal Year");
        fp.ValueFields.Add("Internet Revenue Trend");
        fp.ValueFields.Add("Internet Revenue Status");
        //Add FlexPivotPage to form
        //Intialize KPI Graphics ComboBox
        KpiGraphicsCombo = new ComboBox();
        KpiGraphicsCombo.Left = 160;
        KpiGraphicsCombo.Top = 35;            
        //Populate Combobox with KpiGraphics enum values to alter graphic at runtime
        KpiGraphicsCombo.DataSource = Enum.GetValues(typeof(KpiGraphics));         
        KpiGraphicsCombo.SelectedIndexChanged += KpiGraphicsComboBox_SelectedIndexChanged;
        //Add ComboBox to form
    //Invoke the method to apply the selected KPI graphics
    private void KpiGraphicsComboBox_SelectedIndexChanged(object sender, EventArgs e)
    //Apply the selected graphics to KPI fields
    void Scan(IEnumerable<C1FlexPivotField> list)
        foreach (var field in list)
            if (field is C1KpiField)
                (field as C1KpiField).KpiGraphics = (KpiGraphics)Enum.Parse(typeof(KpiGraphics), KpiGraphicsCombo.SelectedValue.ToString());
            if (field is C1CubeField)
                Scan((field as C1CubeField).SubFields);