SuperCube Process

Overview #

Cube process full classname is \koolreport\cube\processes\SuperCube.

The SuperCube is exactly Cube with some added features. In SuperCube process, you could specify multiple fields for rows, multiple fields for columns and multiple fields for each operators. For example:

use \koolreport\cube\processses\Cube;
class MyReport extends \koolreport\KoolReport
    public function setup()
        ->query("SELECT country,product,sale from tblPurchases")
        ->pipe(new SuperCube(array(
            "rows" => "productCategory, productName",
            "columns" => "orderYear, orderMonth",
            "sum" => "dollar_sales, tax_amount",
            "sum percent" => "dollar_sales, tax_amount",
            "count" => "dollar_sales, order_id",
            "count percent" => "dollar_sales, order_id",
            "avg" => "dollar_sales",

The resulted table will look like this:

Product CategoryProduct NameorderYear - 2014 | dollar_sales - sumorderMonth - 12 | order_id - count...
CarFord Falcon730,00045...
TruckFord F-150480,00032...

Aggregated operator #

The SuperCube process accepts several aggregated operators including "sum", "count", "min", "max", "avg" (version >= 1.0.0) and "count percent", "sum percent" (version >= 2.0.0) and "count distinct", "sum distinct", "count not null" (version >= 3.5.0). Each operator multiple fields whose values are aggregated according to the operator into the data of the summarized table.

Summarized table format #

The summarized table of the SuperCube process includes rows of distinct values of the "row"/"rows" fields (if defined) and columns whose names are in the format of " - | - " or " - {{all}} | - ". Beside those columns there are label columns which are the "row"/"rows" fields and ordered by labels from left to right. Here's an example:

Product CategoryProduct NameorderYear - 2014 | dollar_sales - sumorderYear - {{all}} | dollar_sales - sumorderMonth - 12 | order_id - countorderMonth - {{all}} | order_id - count...
CarFord Falcon730,0001320,0004582...
TruckFord F-150480,0001730,0003298...

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.