Grouping Reporter

Description

Allows results of another reporter to be grouped by any keychain value in each item.

This reporter provides group-by and statistical analysis capabilities for reports. It processes the results of the contained reporter and performs grouping and (optionally) statistical analysis with the companion Grouping Stats macro.

You can also perform simple analysis using the Stats On Supplier to calculate results.


Parameters

NameRequiredAvailable InMigratable to Cloud?Default ValueDescription

[default] /key(s)

 (tick)

Server, Data Center


The comma-separated list of keys to group on. They will be grouped in the order provided, so the second keychain will be a subset of the first.

e.g.: prefix:key > prefix:key, prefix:other key.

To put a comma as part of a single keychain it will need to be double-escaped with a backslash.

as

 (tick)

Server, Data Center


The comma-separated list of names that the groups will be accessible as. There must be the same number of names here as there are keychains.

These are case-sensitive, so use the exact same case when getting the grouped value.


Notes

The grouped items and stats will be available via the Grouped Supplier.

Examples

Weather Data

This is a simple example using basic weather data. It will allow entry of data for each day, and the report will group data monthly and perform some statistical analysis of it.

Data Input

Below is a fairly simple Scaffold table containing a date, min/max temperature, and rainfall.

{table-data:Data}
|| Day || Min Temp (°C) || Max Temp (°C) || Rainfall (mm) ||
| {date-data:name=Date|format=d-MMM-yyyy}today{date-data} | {number-data:name=Min Temp|format=#.# '°C'} | {number-data:name=Max Temp|format=#.# '°C'} | {number-data:name=Rainfall|minValue=0|format=#.# 'mm'} |
{table-data}
Simple Monthly Report

We'll start with a simple monthly report that lists what the maximum and minimum temperature for each month and the total rainfall.

{report-table}
{grouping-reporter:key=data:Date > date:MMMM yyyy|as=Month}
  {grouping-stats:data:Min Temp|as=Minimums}
  {grouping-stats:data:Max Temp|as=Maximums}
  {grouping-stats:data:Rainfall|as=Rainfall}

  {local-reporter:data:Data}
    {date-sort:data:Date}
  {local-reporter}
{grouping-reporter}

{report-column:title=Month}{report-info:grouped:Month}{report-column}
{report-column:title=Min Temp}{report-info:grouped:Minimums > stats:min value|format=#.# '°C'}{report-column}
{report-column:title=Max Temp}{report-info:grouped:Maximums > stats:max value|format=#.# '°C'}{report-column}
{report-column:title=Total Rainfall}{report-info:grouped:Rainfall > stats:sum|format=#.# 'mm'}{report-column}

{report-empty}_No data has been entered yet._{report-empty}

{report-table}
Things to Note:
  • It's important to sort your original reporter to match what you're grouping on, or you will get bad results. In this case, it was the 'Date' data field.
  • 'Month', 'Minimums', 'Maximums' and 'Rainfall' were defined with 'as' parameters and referred to in the actual report via the 'grouped' prefix.
  • 'Month' returns the value that was grouped on, in this cast the 'text' value created by the Date Supplier's format method.
  • 'Minimums', 'Maximums' and 'Rainfall' all return a Stats result from which a variety of statistics are available. In each case we chose just one ('min value', 'max value' and 'sum', respectively), but you can get multiple statistics from the same 'stats' result without any major performance penalty.
Detailed Monthly Report

This is a more advanced report on the same data. This report will group based on the month and year value ('date:MMM yyyy') and perform statistical analysis of the 'Min Temp', 'Max Temp' and 'Rainfall' values in each entry.

{report-table:injected=true}

{grouping-reporter:key=data:Date > date:MMMM yyyy|as=Month}
  {grouping-stats:data:Min Temp|as=Minimums}
  {grouping-stats:data:Max Temp|as=Maximums}
  {grouping-stats:data:Rainfall|as=Rainfall}

  {local-reporter:data:Data}
    {date-sort:data:Date}
  {local-reporter}
{grouping-reporter}

{report-column:title=Month|rowSpan=3}%grouped:Month%{report-column}
{report-column:title=Rainfall (Total)|rowSpan=3}%Rainfall > sum% mm{report-column}

{report-column:title=Lowest Minimum}%Minimums > min value% °C (%Minimums > min item > data:Date > EEE d%){report-column}
{report-column:title=Highest Minimum}%Minimums > max value% °C (%Minimums > max item > data:Date > EEE d%){report-column}
{report-column:title=Average Minimum}%Minimums > value average% °C{report-column}

{report-column:title=Lowest Maximum|newRow=true}%Maximums > min value% °C (%Maximums > min item > data:Date > EEE d%){report-column}
{report-column:title=Highest Maximum}%Maximums > max value% °C (%Maximums > max item > data:Date > EEE d%){report-column}
{report-column:title=Average Maximum}%Maximums > value average% °C{report-column}

{report-column:title=Lowest Rainfall|newRow=true}%Rainfall > min value% mm (%Rainfall > min item > data:Date > EEE d%){report-column}
{report-column:title=Highest Rainfall}%Rainfall > max value% mm (%Rainfall > max item > data:Date > EEE d%){report-column}
{report-column:title=Average Rainfall}%Rainfall > value average% mm{report-column}

{report-empty}_No data to report on._{report-empty}

{report-table}
Things to Note
  • This report uses the new 'rowSpan' and 'newRow' features of report-column to change the layout.
  • We are using 'injection' to make the report a bit more compact. It's turned on in the original {report-table} macro.
  • We are also skipping the optional prefixes, again for brevity. In general it's best to leave prefixes in to make it clearer which supplier is responsible for the particular part of the keychain (self-documentation).
  • We are accessing the 'min item' and 'max item' to display the actual date the minimum and maximum value occurred on. 'min value' and 'max value' will be the original item from the contained reporter (in this case, the {table-data:Data} row, provided by {local-reporter}).

Tutorial Examples

There is no content with the specified labels