KoolReport's Forum

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

Error in Cube function average. #856

Closed Daniel Amamoo-Otchere opened this topic on on May 7, 2019 - 3 comments

Daniel Amamoo-Otchere commented on May 7, 2019

Hello Kool Team,

Greetings.

I am performing an average on a set of values for a report I am building on school performance average.

The code I am using is:

 $node_orig
 ->pipe(new Cube(array(
               "column"=>"subject_code",
                "row"=>"student_name",
		"avg"=>"final_grade",
      
            )))
->pipe(new RemoveColumn(array(
            "{{all}}"
)))
->pipe($this->dataStore("student_trend"));

The report snapshot below shows the error highlighted

Performing the averages outside the koolreport framework I get the following result

Kindly assist with a working solution to that bug.

Also can I use Pivot instead of Cube to build the chart?

David Winterburn commented on May 8, 2019

Hi Daniel,

Would you please send us your dataset either here or via email (if privacy is needed) so that we could test the result? Thanks!

David Winterburn commented on May 9, 2019

Hi Daniel,

We have received your dataset and run your cube setting with it. Here is the result of the students you highlighted in the previous post:

{
        "student_name": "GIDEON KWESI ATTA BINNEY",
        "Env. Stud.": 0,
        "N. Sci": 0,
        "Math": 76.6875,
        "C.Arts": 84.5,
        "Eng": 65.14285714285714,
        "Soc": 69.375,
        "Sci": 78.57142857142857,
        "ICT": 77.25,
        "Citizen": 85.83333333333333,
        "RME": 73,
        "Fan": 76.21428571428571,
        "BDT": 70,
        "Fren": 0
    },
{
        "student_name": "B. AUGUSTA ADJEI",
        "Env. Stud.": 0,
        "N. Sci": 0,
        "Math": 66.85714285714285,
        "C.Arts": 78.83333333333333,
        "Eng": 62.857142857142854,
        "Soc": 71.125,
        "Sci": 74.07142857142857,
        "ICT": 66.83333333333333,
        "Citizen": 85,
        "RME": 72,
        "Fan": 75.28571428571428,
        "BDT": 64.5,
        "Fren": 0
    }

Here's our php code:

//MyReport.php
$this->src('testcsv')
        ->pipe(new Cube(array(
            "column"=>"subject_code",
            "row"=>"student_name",
            "avg"=>"final_grade",
        )))
        ->pipe(new RemoveColumn(array(
            "{{all}}"
        )))
        ->pipe($this->dataStore("student_trend"));

/MyReport.view.php
$ds = $this->dataStore("student_trend");
Util::prettyPrint($ds->data());

I think there's no problem with these results. Please check other parts of your php code to make sure it doesn't alter the cube result. Let us know your opinion. Thanks!

Daniel Amamoo-Otchere commented on May 13, 2019

Thanks for the support Kool Team. Hopefully the updated cube will be available in the new version.

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
None yet

Cube