KoolReport's Forum

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

How to add datafield suffix to measure on PivotTable #946

Closed Ardan Peddell opened this topic on on Jun 26, 2019 - 2 comments

Ardan Peddell commented on Jun 26, 2019

Hi, I am trying to find a way to add a suffix to a Measure/Aggregate column on a PivotTable where the Suffix data comes from a field in the Array.

The example is when displaying sales data for a Vodka Bottle, grouped by warehouse, category - I would like to display the resulting Qty as "2.5 Litre" - the "Litre" coming from the same dataset.

What would be the right datapipe to use to concatenate a second field onto the data?

Any help is much appreciated.

David Winterburn commented on Jun 26, 2019

HI Ardan,

Supposed you could get "Litre" from your datastore, you could suffix the data cells of PivotTable with "map" property:

$measure = "Litre";
PivotTable::create([
    ...
    "map" => [
        'dataCell' => function($value, $cellInfo) use ($measure) {
            return $cellInfo['formattedValue'] . " " . $measure;
        },
    ],
    ...
]);

Let us know if you have any difficulty doing this. Thanks!

Ardan Peddell commented on Jun 27, 2019

Hi David,

Thanks for the example. Will try that and see how it goes.

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