KoolReport's Forum

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

Handling decimal values #225

Open ingmar roos opened this topic on on Mar 6, 2018 - 3 comments

ingmar roos commented on Mar 6, 2018

I want to represent decimal values with two decimal places after comma. If a pass the values to datastore in numeric format only a whole number is shown on report.view.

I use postgreSQL as datasource and have tried to preformat the numbers using postgre built in round function defining 2 decimal places (round(v numeric, s integer) )but it makes no difference.

The only solution that I've found to have the as numbers with two decimal places is to type cast the values to varchar already on SQL query level. (to_char(v numeric::real, '90D99').

This however make it impossible to sum the columns as totals in footer. Aslo when I export such report to excel I will end up having text values on my spreadsheet.

Any recommendations how to do it the right way?

Thank You in advance

KoolReport commented on Mar 6, 2018

Hi,

You should not convert to string, instead you do this:

Table::create(array(
    ...
    "columns"=>array(
        "mycolumn"=>array(
            "type"=>"number",
            "decimals"=>2
        )
    ),
    ...
));

Now you will see that your data in "mycolumn" will have 2 decimals.

ingmar roos commented on Mar 7, 2018

Thank You very much You have a really great product

KoolReport commented on Mar 7, 2018

Thank you :), please allow us to add your compliment to our testimonials page.

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

None