pivottable - Pivottable Spreadsheet Function for an Array
Implements a pivottable function similar to GSheet and Excel functions. Aggregate fields with given operator. Multiple fields can be aggregated. Aggregate functions are: count, sum, min, max and mean.
Aggregate functions :
- count: calculates the count of all values in a set
- sum: calculates the sum of values.
- min: minimum gets the minimum value in a set of values
- max: aximum gets the maximum value in a set of values
- mean: calculates the average in a set of values — not rounded
data
array
Array of objects with at least two properties e.g. [{city,score}] each.
Minimum: 1
Example:
[
{
"name": "Alice",
"score": 1,
"highest": 10
},
{
"name": "Bob",
"score": 2,
"highest": 20
},
{
"name": "Alice",
"score": 4,
"highest": 40
},
{
"name": "Charlie",
"score": 8,
"highest": 80
},
{
"name": "Bob",
"score": 16,
"highest": 160
}
]
index
string
Name of the field in data to be used as index for aggregation. Case sensitive.
Example:
name
aggregateFunctions
array<object>
Aggregate operator per name attribute.
Minimum: 1
Example:
[
{
"field": "score",
"aggregators": [
"sum"
]
}
]
field
string
Name of field
aggregators
array<string>
Aggregator functions
Minimum: 1
Possible values are: count, sum, min, max, mean