...
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
...
In our case we have the attributes already inserted, you can modify the role of an attribute in the pivot view simply by double clicking on an attribute and the following will appear :
In this newly opened View Attribute Configuration Panel, one can modify the details of that attribute, namely one can modify the role it has in that Pivot, the way it aggregates and more importantly the way the Label is used, as it can be used as an Expression, which I will explain further on, in the example.
In the examples bellow, one will see how changing the Pivot Value impacts the way the view behaves.
In this example we can see how the Pivot Value is set for the "Contract Term" and we can easily see which the contract length an account has, emphasised by the True or False values.
To show how the Pivot View changes around the Pivot Value, I have modified the Value to pivot around, and in this case it is now pivoting around when the billing frequency, be it Monthly or just a one time bill.
If by any means we want to sort through the columns we have in here, we will not be able to do so via a Sort Order, instead we will have to change the Pivot Columns Source from "View Data" to "Expression" and now the expression will help sort through the Pivot View.
Clicking on the Pivot Column Source and we will change the "View Data" option to :
To correctly set up the column sort the expression must point to the Pivot Column.
To showcase this I want thee pivot view to only display these Column Names in this particular sort order: Handset , Internet, Voicemail, SIM_Only the expression to be written in the "Pivot Column Expr" field will look like this : ["Handset", "Internet", "Voicemail", "SIM_Only"]
while the Pivot View will look like in the following picture :
...
- 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
- by clicking
- 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: