# Monthly Report from an Apify Dataset - Date Bucket Group By

**Use case:** 

Turn any dataset with a date field into a month-by-month (or day, week, quarter, year) summary: counts and sums per period, sorted, with CSV export.

## Input

```json
{
  "data": [
    {
      "orderId": 1001,
      "region": "North",
      "product": "Widget",
      "amount": "$1,200.00",
      "orderedAt": "2026-07-03"
    },
    {
      "orderId": 1002,
      "region": "North",
      "product": "Gadget",
      "amount": 350,
      "orderedAt": "2026-07-18"
    },
    {
      "orderId": 1003,
      "region": "South",
      "product": "Widget",
      "amount": "890.50",
      "orderedAt": "2026-07-22"
    },
    {
      "orderId": 1004,
      "region": "south",
      "product": "Gizmo",
      "amount": 120,
      "orderedAt": "2026-08-02"
    },
    {
      "orderId": 1005,
      "region": "East",
      "product": "Widget",
      "amount": 2400,
      "orderedAt": "2026-08-05"
    },
    {
      "orderId": 1006,
      "region": "East",
      "product": "Gadget",
      "amount": "n/a",
      "orderedAt": "2026-08-09"
    },
    {
      "orderId": 1007,
      "region": "North",
      "product": "Gizmo",
      "amount": 75,
      "orderedAt": "2026-08-11"
    },
    {
      "orderId": 1008,
      "region": "",
      "product": "Widget",
      "amount": 410,
      "orderedAt": "2026-08-14"
    }
  ],
  "groupByFields": [
    "region"
  ],
  "aggregations": [
    {
      "function": "count",
      "alias": "orders"
    },
    {
      "field": "amount",
      "function": "sum",
      "alias": "revenue"
    }
  ],
  "groupMatching": "normalized",
  "dateBucketField": "orderedAt",
  "dateBucketGranularity": "month",
  "pivotFunction": "sum",
  "lenientNumbers": true,
  "sortBy": "orderedAt_month",
  "sortDirection": "asc",
  "includeTotalsRow": false,
  "exportFormats": [
    "csv"
  ]
}
```

## Output

```json
{
  "region": {
    "label": "Region",
    "format": "text"
  },
  "orders": {
    "label": "Orders",
    "format": "number"
  },
  "total_amount": {
    "label": "Total amount",
    "format": "number"
  },
  "avg_amount": {
    "label": "Avg amount",
    "format": "number"
  }
}
```

## About this Actor

This example demonstrates how to use [Dataset Aggregate, Group By & Pivot](https://apify.com/nerolabs/dataset-aggregate-pivot.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/nerolabs/dataset-aggregate-pivot.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
This Task's input is already configured above — use it as-is rather than inventing a new one.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/nerolabs/dataset-aggregate-pivot.md

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).
