nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.33k stars 1.07k forks source link

Showing multiple aggregates #1348

Open yairlenga opened 8 months ago

yairlenga commented 8 months ago

Hi,

Looking for a way to use pivottable to show mutliple aggregates. In my case, for every group, I need to show the average of two measures and count. The best solution I can think of is to create a new aggregate which will calculate both items, and display them in a cell a string (e.g. 123.45/234.5/12 - meaning first average of 123.45, second average of 234.5 and count of 12.

The main limit is customization - In this approach the user will not be able to choose columns, which is not friendly.

Possible to add this feature - allow for multiple aggregates to be displayed. For my use case, it will work without having support for grouping on column, as per table below. Need the ability to allow the user to choose aggregate/field for each column.

I read the 'Aggregators' section - I can use the example to calculate specific known attributes - main challenge is to provide the user with UI to choose them. Ideally, pivotUI will support this as built-in, eliminate the need to have extra UI on the page.

Thanks, Yair

/ country city avg(income) avg(age) count
USA NYC 123.4 23.1 15000
USA Washington DC 67.2 34.3 18123
USA San-Francisco Cell Cell Cell
GBR London Cell Cell Cell
FRA Paris Cell Cell