Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
Overview
A user may wish to summarise data in a table to get a desired report. The pivot view functionality allows the user to use a table's view attributes as the rows against which data is reported.
Scenario
We have the following car data:
We want to view this data pivoting on Year, and show the data by Car:
Basic Pivot View
Solution
- Open the table's Properties.
- Go to the Views section.
- Create a new View with Display Type Pivot.
- Set the following:
- Name, a useful name indicative of the view's purpose.
- Pivot Column Source, as View Data.
- View Attribute, add the attributes you require by clicking
and dragging in the required attributes in.Insert excerpt _attributes_show _attributes_show nopanel true - Edit the attributes by double clicking:
- Set Role to Pivot Row for the attributes we wish to group on in the rows.
- Set Role to Column for the attribute you want to pivot on. Each unique value will be added as a column.
- Set Role to Row Value for the attribute you wish to aggregate on and set Aggregate Function as required e.g. Sum.
- Maximum Pivot Columns
- This setup is illustrated below:
- This produces the following view:
- To Pivot on Car we can use the following setup, note we have removed Description as we can only pivot on one attribute:
- This produces:
Pivot View with Expression
Expressions allow you to control the headers that are pivoted on. This allows you to sort the pivoted column order and also add entries where no data is provided. In the latter example, if we had no car data for "Car 4" but wished to include it in the report this is achievable using an expression.
Note for expressions
- Pivot Column Headers must begin with a letter.
- We cannot use the expression where a Pivot Column Header is numeric.
- The Pivot Column Headers must match the values of the content within them.
- Spaces are replaced with underscores, this does not need to be reflected in the column headers.
Solution
- Open the Pivot View properties.
- Click on the Pivot Column Source and select
Expression.
- Complete the Pivot Column Expr.:
["Car 1", "Car 2", "Car 3", "Car 4"]
- The setup looks as follow:
- This setup results in:
Pivot View Enhancements
Pivot with Pivot Row Total
This allows us to generate a total for each row in our data.
- Open the View properties.
- Rename the existing Quantity attribute e.g. Quantity_.
- This is necessary as we cant have two attributes with the same name.
- Add Quantity again.
- Double click the newly added Quantity:
- Name,
QuantityByYear
- Role,
Pivot Row Total
- Aggregate Function,
Sum
- Name,
- Save your changes and refresh your view. THe results will be as follows:
Pivot with Column Value Label
It is possible to Pivot on one attribute but use the values from a different attribute as the pivot column header labels.
- Open the View properties.
- Set Pivot Colum Source to
View Data
- Add the Description attribute, or the attribute you wish to use as the label.
- Double click the new attribute to open its properties:
- Set Role to
Pivot Column Label
- Set Role to
- Save all changes and refresh your view. The results will be as follows, where the description field is now the column header: