KoolReport's Forum

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

PivotTable display "-" instead of values #1692

Closed Patryk opened this topic on on Oct 30, 2020 - 7 comments

Patryk commented on Oct 30, 2020

Hi, I'm using koolreport with Codeigniter 3.x. I have migrated from php 5.x to 7.4. After update version of packages via composer my PivotTable report display "-" instead of real value. Before composer run. Everything was fine

function setup()
    {
        //Now you can access database that you configured in codeigniter
        $this->src("default")
            ->query("SELECT * FROM XXX")


            ->pipe(new ColumnMeta(array(
                "SALESVALUEPLN"=>array(
                    "type" => 'number',
                    "decimals" => 0,
                    "thousandSeparator" => ".",
                    "decimalPoint" => ",",
                )
                
            )))

            ->pipe(new Pivot(array(
                "dimensions"=>array(
                    "column"=>"INVOICEYEAR,INVOICEMONTH",
                    "row"=>"CUSTNAME,ORCUSTNAME,ITEMNAME"
                ),
                "aggregates"=>array(
                    "sum"=>"SALESVALUEPLN",
                    //"sum"=>"SALESVALUEPLN"
                )
            )))

            ->pipe($this->dataStore('CustomerSalesCurrentMonth')); 

    }
 $dataStore = $this->dataStore('CustomerSalesCurrentMonth');
  PivotTable::create(array(
    "dataStore"=>$dataStore,
    "rowDimension"=>"row",
    "columnDimension"=>"column",
    "measures"=>array(
      "Wartość sprzedaży", 
      // 'Ilość sprzedanych ton',
      // 'Ilość ton do FV'
    ),
    'rowSort' => array(
      'INVOICEAMOUNTPLN' => 'asc',
    ),
    'columnSort' => array(
      'INVOICEMONTH' => function($a, $b) {
        return (int)$a < (int)$b;
      },
    ),
    'rowCollapseLevels' => array(0),
    'columnCollapseLevels' => array(1),
    'showDataHeaders' => true,
    'hideTotalRow' => false,
    'hideTotalColumn' => true,
    'hideSubtotalRow' => true,
    'hideSubtotalColumn' => true,
    "totalName" => "Suma",
    'width' => '100%',
    'nameMap' => array(
      'SALESVALUEPLN' => 'Sprzedaż PLN',
      //'dollar_sales - count' => 'Number of Sales',
      '1' => 'Styczeń',
      '2' => 'Luty',
      '3' => 'Marzec',
      '4' => 'Kwiecień',
      '5' => 'Maj',
      '6' => 'Czerwiec',
      '7' => 'Lipiec',
      '8' => 'Sierpień',
      '9' => 'Wrzesień',
      '10' => 'Październik',
      '11' => 'Listopad',
      '12' => 'Grudzień',
    ),
  ));
Sebastian Morales commented on Oct 30, 2020

Patryk, please print out the datastore's data in your report's view and post the result:

print_r($this->dataStore('CustomerSalesCurrentMonth')->data());
Patryk commented on Oct 30, 2020

It seems that data are there

Sebastian Morales commented on Oct 30, 2020

Please remove the "measures" property in your PivotTable::create.

Patryk commented on Oct 30, 2020

Worked! Values dispalys correctly. Thank You :)

Ok, the problem was solved, but I would like to have opportunity to give titles of the columns. It's very helpful for the users

Can I do this in some other way?

Sebastian Morales commented on Oct 30, 2020

Great result. Naming measures by using map's dataHeader property per documentation here:

https://www.koolreport.com/docs/pivot/pivottable_and_pivotmatrix/#properties-map-(version-%3E=-5.0.0)

    "map" => [
                'dataHeader' => function($dataField, $fieldInfo) {
                    if ($dataField === "SALESVALUEPLN - sum") return "Wartość sprzedaży";
                    else return $dataField;
                },
Patryk commented on Oct 30, 2020

Awsome... Thank You again :) Have a good friday and weekend

Sebastian Morales commented on Oct 30, 2020

Thanks, you do, too, Patryk.

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
solved

None