Summarizing Column Data
You can perform typical aggregations of column data to create summary information for data tables. The following aggregations are available when summarizing column data:
|
|
By default, aggregations exclude columns with Null values. Create the constant rdCalculationsIncludeNulls in your _Settings definition and set it to True if you want to include them.
You can display the summary information at the bottom of a data table in a dedicated row, on every page or just the last page (if the data spans multiple pages).
To summarize a data column:
- Add a Data Column Summary element beneath a Data Table Column element, as shown above.
- Set its Data Column attribute value to the name of the column to be summarized.
- Select an aggregating function in the Function attribute value.
- Give the element an ID - this is important as the ID may be used later in order to reference the summarized value.
- Set the Data Type attribute value to the proper data type (optional but recommended).
You can add a Data Column Summary element to every data table column that you want to summarize. As mentioned above, the summarized value is available using an @Data token. So, the data in the example above would be available as @Data.sumFreight~. However, you do not need to use this token if you use a Summary Row element to display your summarized data.
As shown above, the Summary Row element is added as a child of the Data Table (its position in the element tree does not matter) and its attributes are set as shown. This will cause a separate row to appear at the end of the report and its Caption will appear in the first column; the summarized values for each column that has a child Summary element will automatically appear in this row.
The example above shows the summary row and summarized Freight column value. The summary row will inherit the format of its data column.
An alternative to using data column summaries is to use datalayer aggregate columns. An aggregate column behaves like any other column in the datalayer, and developers can perform additional calculations using more datalayer column elements.