KoolReport's Forum

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

How to calculate column percentage into footer total value percentage #2986

Open Komuraiah A opened this topic on on Feb 13, 2023 - 1 comments

Komuraiah A commented on Feb 13, 2023

am converting all column values into percentage base and after am trying to calculate percentage column values into footer percentage. is it possible to convert column percentage to footer percentage. please see below screenshot for better understanding

Sebastian Morales commented on Feb 14, 2023

We could not compute footer of a percentage column from it alone without knowing other column values. You have to divide footer values of other columns like this:

    Table::create(array(
        ...
        "showFooter"=>"bottom",
        "columns"=>array(
            ...
            "Conversion(%)"=>array(
                ...
                "footer"=>function($datastore)
                {
                    // Get total values of related columns and compute the total percentage yourself
                    $totalColumn1 = $datastore->sum("column1");
                    $totalColumn2 = $datastore->sum("column2");
                    $totalPercentage = $totalColumn1 / $totalColumn2 * 100;
                    return $totalPercentage . " %";
                }
            ),
        ),
        ...
    )); 

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
help needed

None