FlexPivot for WPF | ComponentOne
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.

    Copy Code
    <Grid>
            <Label Content="Select the appropriate KPI Graphics to display the same in C1FlexPivotage" FontWeight="Bold" FontSize="14" Grid.Row="0" Margin="10,0,182,5" Height="35"/>
            <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10">
                <Label Content="Select KPI Graphics"  FontSize="16" />
                <ComboBox x:Name="KpiGraphicsCombo" SelectionChanged="KpiGraphicsCombo_SelectionChanged" Margin="20,3" Width="307"/>
            </StackPanel>
            <c1:FlexPivotPage x:Name="flexPivotPage" Grid.Row="2"/>
    </Grid
    
    Copy Code
    void Scan(IEnumerable<PivotField> list)
            {
                foreach (var field in list)
                {
                    if (field is KpiField)
                        (field as KpiField).KpiGraphics = (KpiGraphics)Enum.Parse(typeof(KpiGraphics), KpiGraphicsCombo.SelectedValue.ToString());
                    if (field is CubeField)
                        Scan((field as CubeField).SubFields);
                }
            }
            private void KpiGraphicsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                Scan(flexPivotPage.C1PivotEngine.Fields);
            }
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                //Set up connection string
                string connectionString = @"Data Source=http://ssrs.componentone.com/OLAP/msmdpump.dll;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional";
                string cubeName = "Adventure Works";
                //Connect Cube Data to FlexPivotPage
                flexPivotPage.FlexPivotPanel.ConnectCube(cubeName, connectionString);
                //Show KPI Field data in the FlexPivotPage using ValueFields
                var fp = flexPivotPage.C1PivotEngine;
                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();
                //Populate Combobox with KpiGraphics enum values to alter graphic at runtime
                KpiGraphicsCombo.ItemsSource = Enum.GetValues(typeof(C1.PivotEngine.Internal.KpiGraphics));
                KpiGraphicsCombo.SelectionChanged += KpiGraphicsCombo_SelectionChanged;
            }