> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexprice.io/llms.txt
> Use this file to discover all available pages before exploring further.

# SUM

> Sums the values of a specified property across all matching events.

Step-by-Step Setup when creating a SUM-based metered feature:

1. **Navigate to Features**
   * Go to Product Catalog → Features
   * Click "Add Feature"

2. **Basic Information**
   * **Name**: "Data Transfer" (or descriptive name)
   * **Type**: Select "Metered"

3. **Event Configuration**
   * **Event Name**: `data.transfer` (must match your event data)
   * **Aggregation Function**: Sum
   * **Aggregation Field**: `gb` (the property to sum)

4. **Usage Settings**
   * **Usage Reset**: Periodic (for monthly limits) or Cumulative
   * **Unit Name**: `GB / GBs`

5. **Save Feature**

## Calculation Example

### Event Data

```json theme={null}
[
  {
    "event_id": "evt_001",
    "event_name": "data.transfer",
    "external_customer_id": "customer_123",
    "timestamp": "2024-01-15T10:00:00Z",
    "properties": {
      "gb": 5.2
    }
  },
  {
    "event_id": "evt_002", 
    "event_name": "data.transfer",
    "external_customer_id": "customer_123",
    "timestamp": "2024-01-15T10:05:00Z",
    "properties": {
      "gb": 3.8
    }
  },
  {
    "event_id": "evt_001", // Duplicate event ID
    "event_name": "data.transfer",
    "external_customer_id": "customer_123", 
    "timestamp": "2024-01-15T10:10:00Z",
    "properties": {
      "gb": 7.1
    }
  }
]
```

### Calculation Process

1. **Event Matching**: All events with `event_name = "data.transfer"`
2. **Deduplication**: Remove duplicate event IDs, keeping latest value
   * `evt_001` → `7.1 GB` (latest value for this ID)
   * `evt_002` → `3.8 GB`
3. **Sum Result**: `7.1 + 3.8 = 10.9 GB`

**Result**: `10.9 GBs`

## Use Cases

### Data Transfer Tracking

**Perfect for**: Bandwidth usage, file downloads, API data transfer

```json theme={null}
{
  "event_name": "data.transfer",
  "external_customer_id": "acme_corp",
  "properties": {
    "gb": 2.5
  }
}
```

### Compute Time

**Perfect for**: CPU hours, GPU usage, processing time

```json theme={null}
{
  "event_name": "compute.usage",
  "external_customer_id": "user_456",
  "properties": {
    "hours": 1.5
  }
}
```

### Storage Usage

**Perfect for**: Disk space, database storage, file storage

```json theme={null}
{
  "event_name": "storage.usage",
  "external_customer_id": "merchant_789",
  "properties": {
    "mb": 512
  }
}
```

### Credits Consumed

**Perfect for**: AI model usage, API credits, processing credits

```json theme={null}
{
  "event_name": "model.usage",
  "external_customer_id": "customer_101",
  "properties": {
    "credits": 25
  }
}
```

### When to Use SUM

✅ **Use SUM when:**

* Tracking quantities or volumes
* Measuring resource consumption
* Accumulating usage values
* Need precise numeric totals

## Next Steps

* **[Creating a Metered Feature](/docs/event-ingestion/creating-a-metered-feature)** - Complete setup guide
* **[Sending Events](/docs/event-ingestion/sending-events)** - How to transmit SUM events
