Creating a Widget: Pivot Table

 

Pivot tables are one of the most useful widgets for visualizing data. They enable you to quickly summarise and analyze large amounts of data.

Adding Data to a Pivot Table

Select the data to appear in the Pivot.

  1. In the Rows panel, click Add + to select the field(s) whose values will be placed in the rows of the Pivot table.
    You can add up to 20 fields in the Rows panel.
    8-6pivotrowsthumb0300

Note: You can display HTML in your Pivot 2 cells as HTML or plain text, see limitations.

 

  1. When more than one Row is selected, the Rows are broken into sub-rows (groups). For example, the following shows Condition added as a second Row:
    8-6pivotrows2thumb0300
  2. In the Columns panel, click Add + to select the field(s) whose values will be placed in the columns of the Pivot table. You can add up to 3 fields in the Columns panel.
    You can drag and drop the fields that you added to Columns to the Rows area and vice versa.
  3. (Pivot 1 only) In the Values panel, select a field whose values will appear in the Rows and Columns of the Pivot table. You can add up to 20 measures to the Values panel.

Tip: Right-click the value to add data bars to your pivot table.

8-6data-bars1thumb0300

Adding Formulas 

Grand Totals and Subtotals

You can add Grand Totals and Subtotals to your tables, and define how to calculate Subtotals.

To add Grand Totals and Subtotals to rows:

  1. Click on the menu of the Row in the Data Panel, or right-click on the row header in the widget, and select Grand Totals or Subtotals. Subtotals are enabled only if you have more than one row in your table.

    8-6two-rows-subtotalthumb0300

  2. If you selected to display Subtotals, select the method by which to calculate them. Click the menu of the Value in the data panel, and then click Subtotal by and select the method. You can choose different Subtotals in each field. To do this, click the header of the desired value in the table, click Subtotal By and select the method.

    image(176)

Consider the following:

8-6sub-totals-eg4thumb0300

In the top example, using the Auto option, the Subtotal for average revenue aggregates all the sales and revenue data. This represents a true Subtotal of the average revenue for the Asia region.

In the bottom example, Average is used to calculate the Subtotal, and therefore calculates the average of all the average revenue values in the rows above the Subtotal.

Distinct Totals in Pivot Tables

The process of denormalisation of the data sometimes creates duplicates. Duplicates are not a big problem when processing text, because you can always "count distinct". However, they are a big problem when processing numbers because you cannot "sum distinct". 

There is a Total calculation type - Distinct Totals. When enabled, duplicate values are eliminated before the aggregation is calculated.

Analytical Engine calculates the totals, based on distinct values (eliminating any many-to-many impact, and avoiding counting values multiple times.)

The dashboard designer can set the required behaviour for each pivot table.

Example 1

There are two tables in  the database - FILMS and GENRES.

FILMS
ID DURATION
1 100
2 200
3 300
GENRES
FILM GENRE
1 Comedy
1 Horror
2 Drama
3 Comedy
3 Drama

In the dashboard, a pivot table is created, based only on the FILMS table:

FILM DURATION
1 100
2 200
3 300
TOTAL 600

Another pivot table is created, based on the relationship between the FILMS and GENRES tables, where:

  • FILMS = aggregated table (parent)
  • GENRES = attribute table (child)
FILMS DURATION AND GENRE
GENRE FILM ID DURATION
Comedy 1 100
Comedy 3 300
Comedy Subtotal 400
Drama 2 200
Drama 3 300
Drama Subtotal 500
Horror 1 100
Horror Subtotal 100
TOTAL ??

Grand total duration calculation:

  • Auto = 1000
  • Manual Sum = 1000
  • Distinct total = 600

Rows in the aggregated table that do not have a matching row in the attribute table are not counted in the total calculation.

A measure from the aggregated table (FILMS) is NOT duplicated in the sum, regardless of the number of times it appears in the lower granularity attribute table (GENRES).

Grand Totals

Grand totals aggregate the rows in the pivot table.

To add grand totals:

  • Click on the menu of the row in the data panel, or right-click on the row header in the widget, and then click Grand total.

    If defined, the Grand Totals is affected by Subtotals. In the following example, the Grand Total for Average Sales is 10, representing the average sales for two regions (Asia and Europe). In the example below, Average Sales has a Subtotal (see above) set to Sum, and therefore the Grand total is the total of the rows above.

    8-6sub-totals-eg5thumb0300

Rectifying Problems with Grand Totals and Subtotals

In some cases, it may seem that the grand or subtotal are calculated incorrectly. The reason may be just the selected calculation method.

In other cases, you may want to calculate weighted averages in the grand and subtotals, instead of the arithmetic mean that is used by the system.

To rectify problems with Grand Totals and Subtotals:

  • Change the Subtotal By from Auto to Average:

    8-6subtotals-to-averagethumb0300

To calculate weighted averages in the grand and Subtotals:

  • The subtotal by average takes the values in the rows above it, and therefore cannot be set to show a weighted (multi-pass) average. A way to achieve this is to change your formula in a way that when subtotals are set to auto, it will show the weighted average.

    For example, see the below use case (from the Sample Healthcare dashboard), using weighted aggregation:

    8-6subtotal-weighted-averagethumb0300

    Two connected fields are used here: division.ID and Rooms.Division_ID. The two fields are used from the dimension table in 'Rows' and its equivalent in the fact table in the formula.

In this example, we count beds per division, sum the results, and divide this result by the sum of rooms per division. When looking at a specific division, it is the same as counting beds/rooms, but as a total, it is 10/59 (sum/sum) - the weighted average.

 

 

Embedding Images

You can show images in the pivot table if there is a column with the images' urls in the table's data model.
To embed images:

  1. In the Rows panel, click Add + and select the field that contains the images' url.
  2. Click the field's menu and select Show as Images.
    embed-image

Note: In some instances, images will not appear in the widget’s pdf output if the table holds many images and there is a slow connection to the URL where the images are stored.

 

Designing the Pivot Table

Fine-tune the appearance of the PIVOT table, using the following tools.

  • Page Size: Specify how many rows appear in each page. Paging options are provided accordingly. The maximum number of rows per page is 200 rows.

  • Colours: Select the shading properties for the Pivot table's row and column elements.
    8-6pivotcolorsthumb0300

  • Manual Row Height: Enable and enter a Row Height value (in pixels). If you are showing embedded images in your table, the images are resized to fill the row height and may be cropped because the column width is fixed.

  • Auto Height: Automatically sets the Pivot table's widget height based on the content of a single page in the table.

  • Page Size: Specify how many rows appear in each page. Paging options are provided accordingly. The maximum number of rows per page is 200 rows.

Exception Highlighting

Conditional formatting can be used for exception highlighting in a Pivot table. For example, as shown below:

8-6pivotconditionalthumb0300

       

      Limitations of using the Tables Widget

      • Our analytics supports the exporting of pivot tables of up to 1.5 million cells. Attempting to export a higher number of cells might result in a timeout. The below properties of a pivot table increase the probability of reaching a timeout, when dealing with very large tables:

        • Sub totals or Grand totals
        • Complex formulas in Values
        • Data Security rules
        • Widget-level filters
      • To successfully export pivot tables, split large pivot table with many columns to separate smaller pivot tables.

      • In the PDF Report Settings, the first 14 pages of your Pivot table are displayed in the preview window, however, when you export your Pivot table to PDF, the entire table is included, up to 1,000 rows on multiple pages.