Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Unfortunately, the Group process hasn't had a count by distinct value operator yet. We have a similar process called Cube which could do that albeit there's a little bit of code involved:
//MyReport.php
$distinctValues = [];
...
->pipe(new \koolreport\processes\Cube(array(
"customAggregates" => [
"distinctCount" => [
"{initValue}" => 0,
"{aggValue}" => function($aggValue, $value, $field, $row, $dn) use (& $distinctValues) {
if (!isset($distinctValues[$dn])) $distinctValues[$dn] = [];
$columnDistinctValues = $distinctValues[$dn];
if (!in_array($value, $columnDistinctValues)) {
$aggValue++;
array_push($distinctValues[$dn], $value);
}
return $aggValue;
},
]
],
"row" => "date_created",
"distinctCount" => "id_of_something"
)))
->pipe($this->dataStore("ds"));
//MyReport.view.php
//print out the datastore's data to see its columns and values
print_r($this->dataStore("ds")->data());
Pls try this and let us know if there's any issue. Tks,
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo