## Segmented Aggregations

_Segmented Aggregations_ allow you to segment the usage data collected by a single Meter. This capability is very useful for implementing some pricing and billing use cases. This topic introduces an example usage-based pricing use case and explains how to create and work with Segmented Aggregations:

- [Example Use Case](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#example-use-case)
- [Configuration for Example Use Case](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#configuration-for-example-use-case)
- [Creating Segmented Aggregations](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#creating-segmented-aggregations)
- [Pricing Plans with Segmented Aggregations](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#pricing-plans-with-segmented-aggregations)
- [Reviewing Bills for Segmented Aggregation Pricing](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#reviewing-bills-for-segmented-aggregation-pricing)
- [Custom Descriptions for Segmented Aggregations](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#custom-descriptions-for-segmented-aggregations)
- [Using Copy or Cut and Paste to Create and Manage Segment Values](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#using-copy-or-cut-and-paste-to-create-and-manage-segment-values)
- [Using Wildcards or Defaults in Segmented Aggregations](https://docs.m3ter.com/guides/usage-data-aggregations/segmented-aggregations#using-wildcards-or-defaults-in-segmented-aggregations)

## Example Use Case

Suppose you offer a service to companies to perform background checks on employee candidates to support their hiring process. Pricing for this service will vary by candidate location and the level of check done. The service is offered for candidate locations across three countries and you can perform three levels of background check for each location: Standard, Extended, or Complete. If you want to price differently for each possible combination of check for Country/Level, this would mean having to set up multiple Meters/Aggregations to support usage-pricing for all possible combinations. This then places the burden of deciding which Meter to use for pricing on you when sending customer usage data into the m3ter platform. For such cases, you can use Segmented Aggregations on the same Meter usage data, which means you can always send us data for the same Meter and allows a different pricing to be created for each segment.

## Configuration for Example Use Case

Here’s the configuration for the example.

### Meter

Create and configure a single Meter with three Data Fields:

| Data | Field | Category | Example Values |
| --- | --- | --- | --- |
| Candidate location | location | Where | China \| USA \| UK |
| Background check level | type | What | Standard \| Extended \| Complete |
| Number of checks performed | quantity | Measure | 1 |

### Aggregations

First, you can define which Meter Data Fields are part of the segmented Aggregation - for the current example, these are **location** and **type**.

**Tip: Only String Data Fields can be Segmented!** That is: **Who**, **What**, and **Where** Data Fields. Numeric Data Fields, such as **Measure**, **Cost**, and **Income** cannot be segmented.

Second, you can then define different segmented values for the Aggregation, where for each value you want to assign a specific pricing. For the current example, let’s suppose we want to set up six segment values:

| Segments | location | type |
| --- | --- | --- |
| Segment value 1 | China | Standard |
| Segment value 2 | China | Extended |
| Segment value 3 | USA | Extended |
| Segment value 4 | USA | Complete |
| Segment value 5 | UK | Standard |
| Segment value 6 | UK | Complete |

## Creating Segmented Aggregations

This section explains how to create a Segmented Aggregation for the example use case described above. It’s assumed that a Meter with the required three Data Fields has been set up.

**Note: Limit on Segmentation Fields?** The maximum number of fields that can be used for segmentation is **5**.

**To create a Segmented Aggregation:**

1. Select **Metering>Aggregations**. The **Aggregations** page opens.
2. In the **Product** drop-down, select the Product for which you want to create the new Segmented Aggregation.
3. Select **Create aggregation**. The **Create** page opens.
4. Under **Aggregation details**, enter a **Name** and **Code** for the new Aggregation:

5. Under **Meter settings**, select the **Meter** previously created for the example and with the required Data Fields: **Location**, **Type**, and **Quantity**:

6. Enter the **Aggregation settings**:

7. Open the **Segments** panel:

8. In the **Segments** panel, select the Meter fields you want to use to create segments. The panel adjusts to add a first blank row for the selected Meter fields:

9. Enter segment values for the first row and then use the **Add segment** button to successively add the required segments you want to price by. For the current example, we’ve added six segment values using the **Location/Type** Meter fields:

10. Select **Create aggregation**. The **Aggregation details** page opens:

11. If you want to edit an Aggregation’s details, select the **Edit** button, make your changes, and click **Update**.
12. If you want to remove an Aggregation, return to the **Aggregations** page and select the **Delete** button for the Aggregation:

13. Select **Yes** to confirm the delete action.

**Tip: Create Segmented Aggregation using API call?** You can also use the _Create Aggregation_ API call.

## Pricing Plans with Segmented Aggregations

When pricing Plans you can define a pricing for each segmented value set up for an Aggregation. For more details, see [Pricing Plans Using Segmented Aggregations](https://docs.m3ter.com/guides/plans-and-pricing/pricing-plans/pricing-plans-using-segmented-aggregations).

## Reviewing Bills for Segmented Aggregation Pricing

If you use Segmented Aggregations to price your Product Plans, then at billing one line item will be created per Aggregation segment value you’ve used for pricing and any default pricing you’ve used:

- Each Bill line item shows a charge for a priced segment.
- If you do not use a segment value for pricing, then no line item for this appears on the Bill.
