> ## 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 WITH MULTIPLIER

> Sums property values and applies a configurable multiplier.

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

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

2. **Basic Information**
   * **Name**: "API Credits (USD)" (or descriptive name)
   * **Type**: Select "Metered"

3. **Event Configuration**
   * **Event Name**: `api.usage` (must match your event data)
   * **Aggregation Function**: Sum with Multiplier
   * **Aggregation Field**: `credits` (the property to sum)
   * **Multiplier**: `0.001` (rate to apply - e.g., \$0.001 per credit)

4. **Usage Settings**
   * **Usage Reset**: Periodic (for monthly billing) or Cumulative
   * **Unit Name**: `USD` (currency or unit after multiplier)

5. **Save Feature**

## Calculation Example

### Event Data

```json theme={null}
[
  {
    "event_id": "evt_001",
    "event_name": "api.usage",
    "external_customer_id": "customer_123",
    "timestamp": "2024-01-15T10:00:00Z",
    "properties": {
      "credits": 1000
    }
  },
  {
    "event_id": "evt_002", 
    "event_name": "api.usage",
    "external_customer_id": "customer_123",
    "timestamp": "2024-01-15T10:05:00Z",
    "properties": {
      "credits": 2500
    }
  },
  {
    "event_id": "evt_003",
    "event_name": "api.usage",
    "external_customer_id": "customer_123", 
    "timestamp": "2024-01-15T10:10:00Z",
    "properties": {
      "credits": 1500
    }
  },
  {
    "event_id": "evt_001", // Duplicate event ID
    "event_name": "api.usage",
    "external_customer_id": "customer_123", 
    "timestamp": "2024-01-15T10:15:00Z",
    "properties": {
      "credits": 800
    }
  }
]
```

### Configuration

* **Multiplier**: `0.001` (converts credits to USD at \$0.001 per credit)

### Sum with Multiplier Formula

```
final_result = SUM(values) × multiplier
```

### Calculation Process

1. **Event Matching**: All events with `event_name = "api.usage"`
2. **Deduplication**: Remove duplicate event IDs, keeping latest value
   * `evt_001` → `800 credits` (latest value for this ID)
   * `evt_002` → `2500 credits`
   * `evt_003` → `1500 credits`
3. **Sum Calculation**: `800 + 2500 + 1500 = 4800 credits`
4. **Apply Multiplier**: `4800 × 0.001 = $4.80`

**Result**: `$4.80 USD`

## Use Cases

### Currency Conversion

**Perfect for**: Converting between currencies, unit price calculations

```json theme={null}
{
  "event_name": "sales.transaction",
  "external_customer_id": "acme_corp",
  "properties": {
    "amount_eur": 100
  }
}
```

*Multiplier: `1.10` (EUR to USD conversion)*

### Credit-Based Pricing

**Perfect for**: API credits, processing credits, usage tokens

```json theme={null}
{
  "event_name": "api.credits",
  "external_customer_id": "user_456",
  "properties": {
    "credits_used": 250
  }
}
```

*Multiplier: `0.01` (converts credits to dollars)*

### Tiered Rate Calculations

**Perfect for**: Volume discounts, tier-based pricing, rate adjustments

```json theme={null}
{
  "event_name": "data.processing",
  "external_customer_id": "merchant_789",
  "properties": {
    "gb_processed": 500
  }
}
```

*Multiplier: `0.05` (premium tier rate: \$0.05/GB)*

### Unit Conversions

**Perfect for**: Converting units, standardizing measurements

```json theme={null}
{
  "event_name": "storage.usage",
  "external_customer_id": "customer_101",
  "properties": {
    "mb_stored": 1024
  }
}
```

*Multiplier: `0.001` (converts MB to GB)*

### Commission Calculations

**Perfect for**: Revenue sharing, affiliate commissions, partner payouts

```json theme={null}
{
  "event_name": "transaction.revenue",
  "external_customer_id": "partner_user",
  "properties": {
    "gross_revenue": 1000
  }
}
```

*Multiplier: `0.15` (15% commission rate)*

### When to Use SUM WITH MULTIPLIER

✅ **Use SUM WITH MULTIPLIER when:**

* Need to apply consistent rate conversions
* Converting between units or currencies
* Implementing tiered or variable pricing
* Calculating commissions or percentage-based fees
* Standardizing different measurement units

### Configuration Requirements

⚠️ **Critical Notes:**

* **Multiplier must be > 0** - Cannot use negative or zero values
* **Multiplier is immutable** - Cannot be changed after feature creation
* **High precision** - Stored as decimal for accurate calculations
* **Applied after summing** - Sum first, then multiply (not per-event)

## 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 WITH MULTIPLIER events
