KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Table Row Group Calculate Average #1296

Closed Andre Van Der Walt opened this topic on on Feb 12, 2020 - 2 comments

Andre Van Der Walt commented on Feb 12, 2020

Hi,

Please assist, calculate "avg" do not return any value but no problem with "sum", "max" and "min".

"grouping"=>array(

                "Category"=>array(
                    "calculate"=>array(
                        "{sumEvaluations}"=>array("sum","No_of_Evaluations"),
                        "{avgEvaluations}"=>array("avg","Pct_Mark")
                    ),
                    "top"=>"<b>Category {Category}</b>",
                    "bottom"=>"<td><b>TOTAL / AVERAGE </b></td><td><td><td><b>{sumEvaluations}</b><td><b>{avgEvaluations}</b></td><td></td>",
                ),
            ),
KoolReport commented on Feb 12, 2020

Hot fix: please go to line 238 of koolreport\widgets\koolphp\Table.php, you will see:

if (in_array($method, array("sum", "count", "min", "max", "mode"))) {

Make it become:

if (in_array($method, array("sum", "count", "min", "max", "mode","avg"))) {

We have found the issue and fixed it but have not released yet.

Another way (without touching our code) you can do:

"{avgEvaluations}"=>function($store){
    return $store->avg("Pct_Mark");
}

Hope that helps.

Andre Van Der Walt commented on Feb 12, 2020

Sorted thank you

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug
help needed
solved

None