---
title: Aggregate data by time
description: Group and summarize data over time using functions like sum, average, and count.
category: Data Transformation
tags: [aggregation, time series, group by, summarize, date-based]
---

# Aggregate data by time

## Description

The **Aggregate Data by Time** activity enables you to group and summarize records based on a time-based column, such as order date, timestamp, or transaction date. You can define the aggregation period (e.g., month, year, week, day) and apply aggregation functions like `sum`, `average`, and `count` on numerical columns.

Use this activity to:

- Group rows into periods such as months or weeks.
- Summarize numerical data by time ranges.
- Retain or exclude original columns from the output.
- Decide how text values are handled when grouped by time.

> **Use case**: After importing a sales dataset, this activity can be used to generate monthly sales summaries, average unit sales per week, or total transactions per year.

## Input

| Input Type | Required | Description                                                    |
| ---------- | -------- | -------------------------------------------------------------- |
| **Data**   | Required | Tabular input data with text or numeric columns to concatenate |

## Output

| Output Type | Format | Description                       |
| ----------- | ------ | --------------------------------- |
| **Data**    | JSON   | Aggregated dataset by time period |

## Configuration Fields

| Field Name           | Description                                                                                                                                              |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Time Column**      | The column containing time/date values used for grouping.                                                                                                |
| **Period**           | Defines the time interval to group by. Options: `year`, `month`, `week`, `day`.                                                                          |
| **Aggregations**     | List of column-to-aggregation mappings. <ul><li>**Column Name** – Column to aggregate</li><li>**Aggregation Type** – `sum`, `average`, `count`</li></ul> |
| **Include Original** | Toggle to retain the original input data columns. If disabled, only aggregated columns are returned.                                                     |
| **Text Strategy**    | Specifies how text fields are handled in grouped data. Options: <ul><li>`First` – Use first value</li><li>`Last` – Use last value</li></ul>              |

## Sample Input

| Order Date | Sales | Units Sold | Transactions | Product Name |
| ---------- | ----- | ---------- | ------------ | ------------ |
| 2024-01-10 | 500   | 10         | 1            | Product A    |
| 2024-01-15 | 700   | 12         | 1            | Product B    |
| 2024-02-05 | 300   | 5          | 1            | Product A    |
| 2024-02-25 | 900   | 15         | 1            | Product C    |

## Sample Configuration

| Field              | Value                                                                                         |
| ------------------ | --------------------------------------------------------------------------------------------- |
| `Time Column`      | `Order Date`                                                                                  |
| `Period`           | `Month`                                                                                       |
| `Aggregations`     | <ul><li>Sales → `sum`</li><li>Units Sold → `average`</li><li>Transactions → `count`</li></ul> |
| `Include Original` | `false`                                                                                       |
| `Text Strategy`    | `First`                                                                                       |

<!-- ![Aggregate Data by Time](aggregate-data-by-time-img.png) -->

## Sample Output

| Month               | Total Sales | Avg Units Sold | Transaction Count | First Product |
| ------------------- | ----------- | -------------- | ----------------- | ------------- |
| 2024-01-01T00:00:00 | 1200        | 11             | 2                 | Product A     |
| 2024-02-01T00:00:00 | 1200        | 10             | 2                 | Product A     |
