GroupBy

This node allows you to create a list of objects with a selected schema.

This node is helpful when you want to structure data. It takes a list of data as an input and lets you aggregate its metrics based on any dimensions.

Example

Imagine you have a list of ad performance data for several days. Each item represents stats that an ad had on a specific day:

See Example JSON
[
  {
    "ad_id": "ad_123456789",
    "spend": 1000,
    "impressions": 10000,
    "clicks": 100,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_123456789",
    "spend": 1000,
    "impressions": 10000,
    "clicks": 100,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_234567890",
    "spend": 500,
    "impressions": 5000,
    "clicks": 50,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_345678901",
    "spend": 1500,
    "impressions": 15000,
    "clicks": 150,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_456789012",
    "spend": 2000,
    "impressions": 20000,
    "clicks": 200,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_567890123",
    "spend": 1700,
    "impressions": 17000,
    "clicks": 170,
    "date": "2023-02-08"
  },
  {
    "ad_id": "ad_123456789",
    "spend": 1500,
    "impressions": 15000,
    "clicks": 150,
    "date": "2023-02-09"
  },
  {
    "ad_id": "ad_234567890",
    "spend": 800,
    "impressions": 8000,
    "clicks": 80,
    "date": "2023-02-09"
  },
  {
    "ad_id": "ad_345678901",
    "spend": 2000,
    "impressions": 20000,
    "clicks": 200,
    "date": "2023-02-09"
  },
  {
    "ad_id": "ad_456789012",
    "spend": 1700,
    "impressions": 17000,
    "clicks": 170,
    "date": "2023-02-09"
  },
  {
    "ad_id": "ad_567890123",
    "spend": 2500,
    "impressions": 25000,
    "clicks": 250,
    "date": "2023-02-09"
  },
  {
    "ad_id": "ad_123456789",
    "spend": 1700,
    "impressions": 17000,
    "clicks": 170,
    "date": "2023-02-10"
  },
  {
    "ad_id": "ad_234567890",
    "spend": 900,
    "impressions": 9000,
    "clicks": 90,
    "date": "2023-02-10"
  },
  {
    "ad_id": "ad_345678901",
    "spend": 2100,
    "impressions": 21000,
    "clicks": 210,
    "date": "2023-02-10"
  },
  {
    "ad_id": "ad_456789012",
    "spend": 1500,
    "impressions": 15000,
    "clicks": 150,
    "date": "2023-02-10"
  },
  {
    "ad_id": "ad_567890123",
    "spend": 2400,
    "impressions": 24000,
    "clicks": 240,
    "date": "2023-02-10"
  }
]
 

Now we want to know how high the impressions, spend and clicks were for the aggregate of days for each ad id.

 
Notion image
 

We can achieve this by adding a dimension ad_id - this is what we want to group by. Then we set the metrics we want to group clicks, impressions, and spend. The node currently only supports aggregation (addition) of metrics.

 

As a result, we get an array of items with the aggregated metrics by ad_id:

[
  {
    "ad_id": "ad_123456789",
    "spend": 5200,
    "impressions": 52000,
    "clicks": 520
  },
  {
    "ad_id": "ad_234567890",
    "spend": 2200,
    "impressions": 22000,
    "clicks": 220
  },
  {
    "ad_id": "ad_345678901",
    "spend": 5600,
    "impressions": 56000,
    "clicks": 560
  },
  {
    "ad_id": "ad_456789012",
    "spend": 5200,
    "impressions": 52000,
    "clicks": 520
  },
  {
    "ad_id": "ad_567890123",
    "spend": 6600,
    "impressions": 66000,
    "clicks": 660
  }
]
 
 

Input Fields

field
schema
explanation
items
any
The list of items that you want to group.
dimensions
pointers
The dimensions, by which you want to group. I.e. group by id, date,…
metrics
pointers
The metrics that you want to aggregate.

Output Fields

field
schema
explanation
items
any
The list of grouped items.
 
Did this answer your question?
😞
😐
🤩

Last updated on February 8, 2023