KoolReport's Forum

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

Format columns created by PivotProcess #2310

Closed Aljaz Ketis opened this topic on on Aug 30, 2021 - 5 comments

Aljaz Ketis commented on Aug 30, 2021

I am creating a counter for some informations with the help of Pivot proccess..it counts the occurance of items ids based on some region and displays the counter isnide a pivot table in excell. How can I modify the cell value, currently the count is shown with 2 decimal numbers but I don't want decimals becouse if it counts it will always be a round number.

Sebastian Morales commented on Aug 31, 2021

Pls set the count field's column meta's decimals to 0 like this:

->pipe(new \koolreport\core\ColumnMeta(array(
    "countField" => array( //replace "countField with your count field name
        "decimals" => 0
    )
))
->pipe(new Pivot(...))
Aljaz Ketis commented on Aug 31, 2021

I did that but nothing changes, as you can see from the code I remove decimals from the column i count and it still displays decimals

->pipe(
                    new ColumnMeta(
                        array(
                            "id"                   => array(
                                "decimals" => 0
                            ),
                        )
                    )
                )
                ->pipe(
                    new Pivot(
                        array(
                            "dimensions" => array(
                                "column" => "report",
                                "row"    => "realm",
                            ),
                            "aggregates" => array(
                                "count" => "id",
                            ),
                        )
                    )
                )

Sebastian Morales commented on Aug 31, 2021

This seems to be a bug with the "count" operator. Pls try to set the meta after Pivot like this:


                ->pipe(
                    new Pivot(
                        array(
                            "dimensions" => array(
                                "column" => "report",
                                "row"    => "realm",
                            ),
                            "aggregates" => array(
                                "count" => "id",
                            ),
                        )
                    )
                ) 
               ->pipe(
                    new ColumnMeta(
                        array(
                            "id - count" => array(
                                "type" => "number",
                                "decimals" => 0
                            ),
                        )
                    )
                )

We will fix this in the next version of Pivot package. Tks,

Aljaz Ketis commented on Aug 31, 2021

I tried that one too, still the same format of cell in excell.

Sebastian Morales commented on Aug 31, 2021

Oh, I just realize you used Excel exporting PivotTable. In that case, at the moment we have a default format code for type "number" which uses 2 decimals point. We will make the format code customizable in the next version of Pivot package. Meanwhile, you could try this workaround for the count field by using type "string" instead of "number":


                ->pipe(
                    new Pivot(
                        array(
                            "dimensions" => array(
                                "column" => "report",
                                "row"    => "realm",
                            ),
                            "aggregates" => array(
                                "count" => "id",
                            ),
                        )
                    )
                ) 
               ->pipe(
                    new ColumnMeta(
                        array(
                            "id - count" => array(
                                "type" => "string"
                            ),
                        )
                    )
                ) 

Let us know if it works for you. Tks,

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

Pivot