KoolReport's Forum

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

Row to column #223

Open michelp opened this topic on on Feb 28, 2018 - 6 comments

michelp commented on Feb 28, 2018

Hi,

I have generated this report:

However, I want to have the periods on top, so that you can get something like this:

How can I do this? Should I use transpose or cube for this?

KoolReport commented on Feb 28, 2018

Please use the Cube process. Here is the documentation.

michelp commented on Feb 28, 2018

Great, thanks

I managed to get all data in my report that I wanted. However I have a strange sorting issue. However, the periodes are not sorted correctly. 2017-3 is in the wrong place

$this->src('yunoport')
            ->query("Select companyname,companyparentid, tblresultid, DATE_FORMAT(tblresultdatetime,'%Y-%m-%d') as resultdate from ci_wizard_results  LEFT JOIN ci_kiosks on ci_wizard_results.tblresultkioskname = ci_kiosks.kioskname LEFT JOIN ci_companies on ci_kiosks.kioskcompanyid = ci_companies.companyid WHERE `tblresultdatetime` >= DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -1 YEAR),'%Y-%m-%d') AND companyname <> ''")
            ->pipe(new Sort(array(
                "companyparentid"=>"asc",
                "tblresultid"=>"desc",
            )))



            ->pipe(new TimeBucket(array(
                "resultdate"=>"month"
            )))
            




            ->pipe(new Cube(array(
                "row"=>"companyname",
                "column"=>"resultdate",
                "count"=>"tblresultid",
                "sort"=>false
            )))
            ->pipe(new ColumnMeta(array(
                "{{all}}"=>array(
                    "type"=>"string",
                    "label"=>"Total",
                    "sort"=>false
                ))))
            ->pipe(new ColumnMeta(array(
                "companyname"=>array(
                    "type"=>"string",
                    "label"=>"Company",
                    "sort"=>false
                ))))





            ->pipe($this->dataStore("wizardresults"));

KoolReport commented on Feb 28, 2018

Please use the ColumnSort to sort column by name

Example

->pipe(new ColumnsSort(array(
    "{name}"=>"asc", 
)))
michelp commented on Feb 28, 2018

Thanks!

Can I exclude the company and total columns from the sorting? Because this causes:

michelp commented on Feb 28, 2018

ok, solved this by adding names to company & total columns and naming them A & B :)

What I am wondering if I can add a total row as well, of the columns above?

So a row that would show 12 - 2 - 4 - 1 - 5

KoolReport commented on Mar 1, 2018

Yes, you can, please use the "footer" of table. Please check the Aggregated Footer in Table documentation.

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