---
title: Aggregate data by column
description: Group and aggregate your dataset by one or more columns using functions like sum, average, and count.
category: Data Transformation
tags: [aggregation, group by, data transformation, summarize]
---

# Aggregate data by column

## Description

The **Aggregate Data By Column** activity allows you to group and summarize data based on one or more column values. You can apply aggregation functions such as `sum`, `average`, and `count` to selected columns. This is useful for generating summaries, totals, or grouped reports from tabular data.

Use this activity to:

- Group data by one or more key columns.
- Apply aggregation functions like sum, average, or count.
- Retain or discard original columns as needed.
- Manage how text columns are handled during aggregation.

> **Use case**: After importing transactional data, you can use this activity to calculate total sales per category, count of orders, or average unit price grouped by product or region.

## Input

| Input Type | Required |
| ---------- | -------- |
| **Data**   | Required |

## Output

| Output Type | Format | Description                      |
| ----------- | ------ | -------------------------------- |
| **Data**    | JSON   | Aggregated dataset as per config |

## Configuration Fields

| Field Name               | Description                                                                                                                                                                               |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Group By Column**      | One or more columns used to group the data.                                                                                                                                               |
| **Aggregations**         | List of columns and their corresponding aggregation functions. <ul><li>**Column** – Name of the column to aggregate</li><li>**Aggregation Type** – `sum`, `average`, or `count`</li></ul> |
| **Include Original**     | Toggle to retain original input columns in the output. If disabled, only grouped and aggregated columns are returned.                                                                     |
| **Text Column Strategy** | Defines how to handle text fields during aggregation. Options: <ul><li>`First` – Retains the first text value in each group</li><li>`Last` – Retains the last text value</li></ul>        |

## Sample Input

| Category    | Total Sales | Units Sold | Product Name |
| ----------- | ----------- | ---------- | ------------ |
| Electronics | 50000       | 50         | Laptop       |
| Electronics | 50000       | 50         | Phone        |
| Furniture   | 60000       | 40         | Sofa         |
| Electronics | 50000       | 50         | Laptop       |
| Clothing    | 20000       | 30         | T-Shirt      |
| Clothing    | 20000       | 30         | Ethnix       |
| Furniture   | 60000       | 40         | Bed          |
| Clothing    | 40000       | 30         | Pants        |

## Sample Configuration

| Field                  | Value                                                              |
| ---------------------- | ------------------------------------------------------------------ |
| `Group By Column`      | `Category`                                                         |
| `Aggregations`         | <ul><li>Total Sales → `sum`</li><li>Units Sold → `first`</li></ul> |
| `Include Original`     | `false`                                                            |
| `Text Column Strategy` | `First`                                                            |

<!-- ![Aggregate Data By Column](aggregate-data-by-column-img.png) -->

## Sample Output

| Category    | Total Sales | Units Sold | Product Name |
| ----------- | ----------- | ---------- | ------------ |
| Electronics | 150000      | 50         | Laptop       |
| Clothing    | 80000       | 30         | T-Shirt      |
| Furniture   | 120000      | 40         | Sofa         |
