GROUPBY

Creates an object from an array and a key expression which determines the key for each item, and a value expression which determines the value.

Syntax

=GROUPBY(array, keyExpression, valueExpression)

Arguments

ArgumentTypeDescription
arrayStringThe array to use.
keyExpressionAnyThe expression which determines which key to use for the item in the array.
valueExpressionArrayThe expression which determines which value to use for the item in the array.

Examples

For these examples, the shape data property "Array" is an array with the values:

[ ["James", 1, 10], ["Mary", 2, 20], ["Robert", 3, 30], ["Michael", 4, 40], ]

=GROUPBY(@Array, x => x[1], x => x[2]){"James": 1, "Mary": 2, "Robert": 3, "Michael": 4}
Creates an object from the array values, grouping by the first element in each array, where the value is the second element

=GROUPBY(@Array, this[1], this[3]){"James": 10, "Mary": 20, "Robert": 30, "Michael": 40}
Creates an object from the array values, grouping by the first element in each array, where the value is the second element