Hi Paulo,
What you describe is currently not possible with the standard Pivot process and PivotTable widget. However, we do have another process called Pivot2D:
->pipe(new Pivot2D(array(
//"column"=>"year",
"row"=>"academic_term, grade"
"aggregates"=>array(
"count"=>"grade",
"count percent"=>"grade",
)
)))
which results in a normal table format. From there you could use the Map process to change the count percent column:
use \koolreport\core\Utility as Util;
...
//->pipe(Pivot2d) code
->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row, $metaData, $index, $mapState) {
$allRows = Util::get($mapState, 'allRows', []);
array_push($allRows, $row);
$mapState['allRows '] = $allRows;
return ['{rows}' => null, '{state}' => $mapState];
},
"{end}" => function($count, $mapState) {
$allRows = Util::get($mapState, 'allRows', []);
//loop through all rows
//if a row is 2nd level, i.e its label column is like "1 Trimester || 0"
//find its parent row label of which is like "1 Trimester || {{all}}"
//divide that row's count percent column by its parent row's count percent column
//the count percent column name should be like "{{all}} || grade - count percent"
return $allRows;
}
)))
->pipe($this->dataStore("newCountPercentPivot"));
Finally display the datastore "newCountPercentPivot" with a PivotTable widget.
For better understanding, I suggest you pipe the Pivot2D's result to a datastore and show its content with Table or DataTables widget.
Let us know if you have any difficulty. Thanks!