Group

To group the input data by one or multiple fields. For each distinct grouping, the output data contains accumulated value from selected fields.

Group is often used when you try to "bucket" data together.

The first part is called Group by. This is where you specify the fields that should be used to group the input data. The field you select here is called a group key and each group key should be unique. For example, you can group all the transactions by the sender's wallet address.

A group key can also be an object:

For details on how to use "toObject" operator, please refer to the Function operators page

If the group key you choose happen to be a timestamp, there will be an extra option for different intervals. It's especially handy when you are building a daily, weekly or monthly chart.

The second part is called Accumulation. This is where you decide how the data that's been grouped together should be handled. There is a list of accumulators to help you achieve that. Let's look at some simple examples:

You can put all of them into an array by using push

If you want to get an average value of all the data, you can use average

If you want to get a total value of all the data, you can use sum

Last updated