sub_totals
sub_totals
sub_totals($group_by_column, $function, $affected_columns)
Parameter | Description |
---|---|
$group_by_column | The column by which the report is grouped. In the below code example, "Country" is the $group_by_column |
$function | The subtotal function. It should be one of the following functions: SRE_SUM, SRE_AVERGAE, SRE_COUNT, SRE_MAX, or SRE_MIN. |
$affected_columns | An array of the columns on which you want to apply the subtotals function. |
use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once "sre_bootstrap.php";
$report = new ReportOptions(SRE_PUBLIC_REPORT);
$report->select_tables(array("items"))
->set_grouping(array("Country"))
->sub_totals("Country", SRE_COUNT, array("price"))
->select_all_fields();
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
if ($report_path) {
echo "Report created successfully! Your report URL: $report_path ";
}