ReportBuilder supports several new features in V4:
If the number of columns exceeds a configurable value (10 by default), reports automatically switch to more compact CSS. A link to toggle the compact view will be added to the report footer.
To change the number of columns that triggers this CSS change, using the configuration setting report.compact_columns
.
Compact views use the ellipsis overflow CSS rule, which truncates data, and keeps it to a single line. This keeps your report entirely within your horizontal screen space, and maximizes the number of rows visible at once. If you toggle back to normal view, the report may exceed your page margins.
Reports can be saved and reloaded later by a different process:
$report->save("unique key",$optional_number_of_days);
The second days parameter determines how long the report will be saved for. Later, you can re-load the report using:
$report->load("unique key");
and display, export, or modify it. (You need to re-save if you want your modifications preserved.)
Saved reports can be made available to the Database Query module; simply list the report keys you want to be able to view in Query.conf, like so:
saved_reports = Report #1 saved_reports += Report #2
... etc
Saved reports are good for:
Reports are saved to the report table, with the following columns:
Note that parameters and scheduling are not fully supported yet.
If you save multiple reports under the same title, they will all be treated as different instances of the same report. The most recent one will be used as the "current" report, whereas all previous ones will be treated as archived versions.
This allows you to build time-series reports to track the evolution of your data. Archived reports will be preserved until their expiry date and then removed, so you can set the expiry to be 1 year in the future, and then regenerate the report monthly; that would leave you with a time series showing the last 12 months at any given time.
You can preload a volume of raw data into a report, and then generate numerous reports by applying filters and rules to the raw data.
Raw data is one datahash per row, ie. a set of key => value pairs, using the same keys in each row. Preload your data using:
$report->rawhead(%head); # key => header name $report->rawdata(@data); # each array element is a row/datahash $report->rawpush(@data); # add more rows
Then generate a report using:
$report->select(%opt);
To select rows, use any of the following comparator options:
If you specify no conditions, rows will be automatically selected for display.
To apply logical operators to your conditions, use these options:
To select which columns to display in the final report, include a columns option:
columns => [ array of keys to include in the output ]
Then you can call make, export, or save, as usual.
You can include any number of conditions in the options, for example:
# select rows where a<5 and b>10 and c==15 $report->select(lt=>{a=>5},gt=>{b=>10},match=>{c=>15});
By default, the conditions are combined with a logical AND, ie. all conditions must match for a row to be selected. Set method=>"or" to combine with a logical OR instead, ie. ANY condition may match for a row to be selected.
Use reselect=>and|or to perform multiple passes on the data in a similar way. This lets you create more complicated logical tests, for example:
# select rows where (a<5 || b<10) && (c==3 || d==6) # first, select rows where a<5 OR b<10 $report->select(lt=>{a=>5,b=>10},method=>"or"); # of the selected rows, select rows where c==3 or d==6 $report->select(match=>{c=>3,d=>6},method=>"or",reselect=>"and");
# select rows where (a<5 && b<10) || (c==3 && d==6) # first, select rows where a<5 and b<10 $report->select(lt=>{a=>5,b=>10}); # method=>"and" assumed by default # also include rows where c==3 and d==6 $report->select(match=>{c=>3,d=>6},reselect=>"or");
Filtered reports are the engine behind interactive report builders:
The user interface for this will depend on the modules generating the reports. Examples can be found in the Membership report builder, and the Forms filtered responses.