The merge source provides a mechanism for merging and filtering the data resulting from two or more other “sub-reports”. This can be useful if you need to combine results from two different databases or with two different key ranges into one report.
When building a merged report, you must specify the reports to merge in a report attribute:
merged_reports: Specifies the sub-reports you want to merge. Provide the reports as a dict with the keys naming the sub-reports and the values being the sub-report classes themselves. For example:
merged_reports = {
'revenue': ProductRevenueReport,
'awesome': UserAwesomenessReport,
}
All merge columns take the same positional arguments, which are used to specify which columns from sub-reports should be combined into the merge column. You can specify the merge columns as follows:
As a merged report is processed, it will actually run the full end-to-end run-report process for each of its sub-reports. It will then aggregate the results together based on the columns and filters in the merge report.
Merges sub-report columns by summing the values returned by each sub-report. Takes the standard merge column arguments, as described above.
Merges sub-report columns by keeping the first value returned by any sub-report. Takes the standard merge column arguments, as described above.
Merges sub-report columns by performing a boolean-and operation over the values returned by the sub-reports. This returns True if all the values from sub-reports are truthy; otherwise, it returns False. A None value is considered True here so that they essentially are ignored in determining the result. Takes the standard merge column arguments, as described above.
Merges sub-report columns by performing a boolean-or operation over the values returned by the sub-reports. This returns True if any of the values from sub-reports are truthy; otherwise, it returns False. A None value is considered False here so that they essentially are ignored in determining the result. Takes the standard merge column arguments, as described above.
Allows you to display one widget from the merge report, then supply the user input to each of the sub-reports to process as they normally would using the filters defined on each sub-report.
This filter simply takes the standard widget keyword argument. You also need to ensure that the name of this filter matches the name of any sub-report filters you want to pick up the user input.
This filter can be used to exclude entire rows from the output, based on the data in the row from the sub-reports.
This takes one positional argument, which should be a filtering function. The function takes the merged row as a dict, and optionally the user input if a widget is specified. If the function returns a truthy value, the row will be included; otherwise, it will be skipped. For example:
merge.PostFilter(
lambda row, user_input: row['revenue'] >= user_input,
widget=widgets.Select(choices=MIN_REVENUE_CHOICES))
This filter allows you to selectively include or exclude specific sub-reports from being processed at all. It takes one positional argument: the name of the sub-report from the merged_reports report attribute from the merge report.
This filter requires a widget (it would be pretty silly to use this one without a widget). It will include the specified sub-report in the merged output only if the user input is truthy. Generally, a Checkbox widget is appropriate for this.