KoolReport's Forum

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

Sum of Max values as Total #86

Open bysystem opened this topic on on Aug 22, 2017 - 16 comments

bysystem commented on Aug 22, 2017

Dear all,

I need to SUM all the aggregated MAX values of 2 colums (BestandHaendler_aktuell AND BestandZentrale_aktuell) as a TOTAL line. But however I get only MAX value in the TOTAL line!! How can I implement this?

My setup:

	->pipe(new Pivot(array(
		"dimensions" => array(
		"column" => "",
		//"row" => "WerbegruppeVerbund, NikonKdName, NikonOrt, NikonProdGruppe, NikonArtBez"
		"row" => "WerbegruppeVerbund, NikonKdName, NikonArtBez, NikonOrt"
		),
		"aggregates" => array(
			"max" => "BestandHaendler_aktuell, BestandZentrale_aktuell",
			//"sum" => "BestandHaendler_aktuell, BestandZentrale_aktuell"
	)
	)))
	->pipe($this->dataStore('Reporting.autorep_v_Bestaende'));

My view:

		<?php
			PivotTable::create(array(
			  "dataStore"=>$this->dataStore('Reporting.autorep_v_Bestaende'),

			  "measures" => array(
				"BestandHaendler_aktuell - max",
				"BestandZentrale_aktuell - max",
			  ),
				  
			  "headerMap" => array(
				"BestandHaendler_aktuell - max" => "(Stand gestern): Bestand-Händler",
				"BestandZentrale_aktuell - max" => "Bestand-Zentrale",
			  ),
			 
			  "rowCollapseLevels" => array(0,1,2), //0 = zu, 1 = auf
			  "columnCollapseLevels" => array(1,2),
			  
			  "totalName" => '<div align="right"><strong>TOTAL</strong></div>'
			 
			));
		?>

The TOTAL result should be in the example below 8 instead of 4 (this is max of all results):

Any hint?

KoolReport commented on Aug 22, 2017

This is not possible. The max operation will apply to all the table.

bysystem commented on Aug 22, 2017

Understood! How can I remove the TOTAL lines completely. Because this makes no sence!

bysystem commented on Aug 23, 2017

Sorry for asking again: How can I remove the TOTAL rows completely as these make no sense!

KoolReport commented on Aug 23, 2017

Do you mean all 3 total rows?

bysystem commented on Aug 23, 2017

Yes please! Of course there are more TOTAL rows when I have more product rows or customer rows etc. None of them is needed!

If I would have the possibility to assign a CSS class or id (for example "total") to each TOTAL row then I would do like:

.total tr {display:none}

bysystem commented on Aug 24, 2017

Any idea?

KoolReport commented on Aug 24, 2017

I have told the pivot developer to answer you. He is working on a solution. Be patient :)

bysystem commented on Aug 24, 2017

:)) Ok thx a lot! I'm looking forward!

David Winterburn commented on Aug 24, 2017

Hi bysystem,

If you have the Pivot package version >=2.1, please add the following properties to the PivotTable widget to hide the Total row or column:

<?php
PivotTable::create(array(
  ...
  'hideTotalRow' => true,
  'hideTotalColumn' => true,
  ...
));

Thanks!

bysystem commented on Aug 24, 2017

Thx a lot David. I'm not sure which version of pivot I have. Where can I see this?

If not possible can u please send me the version 2.1 to my email address?

KoolReport commented on Aug 24, 2017

We've just updated version of Pivot. You may go to Licenses section to download new version.

bysystem commented on Aug 24, 2017

Thx a lot support team,

I just downloaded the pivot vers. 2.1 and updated the pivot folders.

There is a strange situation:

In my view I added hideTotalRow and hideTotalColumn:

				PivotTable::create(array(
				  "dataStore"=>$this->dataStore('Reporting.autorep_v_Bestaende'),

				  "measures" => array(
					"BestandHaendler_aktuell - max",
					"BestandZentrale_aktuell - max",
				  ),
					  
				  "headerMap" => array(
					"BestandHaendler_aktuell - max" => "(Stand gestern): Bestand-Händler",
					"BestandZentrale_aktuell - max" => "Bestand-Zentrale",
				  ),
				 
				  "rowCollapseLevels" => array(0,1,2), //0 = zu, 1 = auf
				  "columnCollapseLevels" => array(1,2),
				  
				  //"totalName" => '<div style="display:none" align="right"><strong>TOTAL</strong></div>',
				  
				  "hideTotalRow" => true,
				  "hideTotalColumn" => true,
				 
				));

Problem 1: Then total columns are not appearing >> this is fine! BUT all my other value colums are gone as well!

If I comment out hideTotalColumn as follows the I get the first view of the pivot table without the Total row >> This is fine:

				  "hideTotalRow" => true,
				  //"hideTotalColumn" => true,

Problem 2: But if I expand the columns the Sub total rows are still there!

How could be solved these 2 problems?

Kind regards,

David Winterburn commented on Aug 25, 2017

Hi bysystem,

The hideTotalColumn and hideTotalRow options only hide the grand total column/row, not the sub total columns/rows.

In the first case, you have no column field so when you hide the grand total column, there's no column left to be shown.

In the second case, the sub total rows are still items with data. For example, the Expert Benning's Total must be kept in the table, otherwise when you collapse it which row is supposed to be shown?

Please let us know your opinion. Thanks!

bysystem commented on Aug 25, 2017

Hi David,

point 1) Ok, understood!

point 2) As you (or your colleague) mentioned in your previous post that it's not possible to have subtotals of MAX values as a Summary instead of MAX, and it's seemly not possible to hide the subtotals in the pivottable because of collapsing etc: my question then:

As I don't need the collapse functionality in this view, How can I create the view in the screenshot above with a simple TABLE widget? Means: - the result view should be the same as my screenshot above, but WITHOUT repeating Expert Biening from the 1st column in each row, WITHOUT repeating the column 2 content in each row etc... Of course WITHOUT having subtotals.

bysystem commented on Aug 27, 2017

I guess we can close this incident as "solved". I could use the rowCollapseLevel function array(2) to render my desired view in the PivotTable!

As a suggestion for the future version it could be a good idea and very helpfull to have a PivotTable property "hideSubTotal".

David Winterburn commented on Aug 28, 2017

Hi bysystem,

We will consider this option for future release of the Pivot package. Thanks much for your suggestion!

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
suggestion

Pivot