-
Notifications
You must be signed in to change notification settings - Fork 2
Summaries
You can summarize by adding the attribute summarizable
to the field on init.
{name: 'last_name', type: 'string', filterable: true, summarizable: 'count' }
There are a few built in functions that can be used on a summarizable field ('sum', 'avg', 'count', 'min','max'). If you would like to define your own simply pass an anonymous function in the field declaration. The functions will be applied to each cell in the cvs that matches the filter criteria.
For example,
If you were to filter by last_name='Jackson' and set summarizable to 'count' it would give you a count of 3 when you called pivot.results()[0].last_name_count
. The reason for the empty string is because no label fields were set. Each combination of labels has its own object in results(an array of objects) that corresponds to the summarized values.
Fields of type 'currency' that contain different currency symbols will error if they are attempted to be aggregated. The value in the result will contain the text 'Multiple-Currency-Error'.