Compound Aggregations allow you to derive numerical measures from usage data by applying a calculation to one or more simple Aggregations. The calculation can also reference Custom Fields. You can then use these calculated measures as pricing metrics to set up usage-based pricing Plans for your Products. In this way, Compound Aggregations can help you to implement a wide range of pricing use cases for your Products. This topic starts off by explaining the difference between Product-specific and Global Compound Aggregations: The topic then illustrates the value of using Compound Aggregations with a usage-based pricing example, and explains how to create a Compound Aggregation to apply a calculation to simple Aggregations to satisfy the example pricing use case:Documentation Index
Fetch the complete documentation index at: https://docs.m3ter.com/llms.txt
Use this file to discover all available pages before exploring further.
Product vs. Global Compound Aggregations
You can create Product Compound Aggregations, which belong to a specific Product, or Global Compound Aggregations, which are not tied to a specific Product:- You can use a Product Compound Aggregation to price only those Plans that belong to the same Product.
- You can use a Global Compound Aggregation to price Plans belonging to any Product.
Example Use Case
Suppose you provide a service which allows your customers to develop and run software applications and host these applications on your service. You intend to charge customers for this application build-and-host service by total number of requests made to all of their applications being hosted in any given billing period. However, you want to offer customers a sign-up bonus for their first year of using your service, where the first 100 requests made to an application they host with you are free for each billing period - for example, if a customer has 3 applications hosted with you during the first billing period, they are due 300 free requests for the first Bill. To set things up in m3ter to implement usage-based pricing for this type of case, you can use a Compound Aggregation:- First, create and configure a Meter which will record the number of applications hosted. You can send an event into m3ter each time one of your customers creates and loads an application into your service. Use this Meter field to create a simple Aggregation to give a Maximum value measure for hosted applications. Give this simple Aggregation a code of: unique_apps. (Note that for the example, we suppose that under the terms of the sign-up bonus if a customer reaches 5 applications in any given billing period, they are granted 500 free requests even if 2 of those applications are disabled before the end of the billing period.)
- Second, create and configure a Meter to record the number of requests made by applications. You can then create a second simple Aggregation to Sum this data. Give this simple Aggregation a Code of: num_requests.
- Third, create a Compound Aggregation that applies a calculation to the two simple Aggregations to give a number for chargeable requests:
Math.max(0, aggregation.num_requests - (aggregation.unique_apps * 100))
When you come to price up your Product Plans, you can now use this Compound Aggregation.
Creating a Compound Aggregation
This section explains how to create a new Product Compound Aggregation for the example use case outlined above, and assumes the two simple Aggregations used have already been created for the same Product. To create a Compound Aggregation:- Select Metering>Compound aggregations. The Compound aggregations page opens.
- In the Product drop-down, select the Product for which you want to create the new Compound Aggregation. The Compound aggregations page adjusts and lists:
- Any existing Compound Aggregations created for the selected Product.
- Any Global Compound Aggregations, which are clearly labeled.
- Select Create compound aggregation. The Compound aggregations>Create page opens.
- Enter the Compound aggregation details:
- Name. (Required) For this example, enter a descriptive name, such as Requests minus free.
- Code. (Required) Unique identifier. For this example, we’ve used requests***_***minus_free.
- Accounting product. Use the drop-down to select a Product. (Optional)
- For accounting purposes, you can use this to link to a specific Product any usage line items on Bills that result from pricing a Plan using this Aggregation:
- If you’ve also defined an Accounting product for a Pricing that uses this Aggregation, then the Pricing Accounting product takes precedence and is used.
- If no Accounting product is defined for a Pricing and you omit an Accounting product for the Aggregation, then the Product the Plan belongs to is used.
- For accounting purposes, you can use this to link to a specific Product any usage line items on Bills that result from pricing a Plan using this Aggregation:

- Enter the Compound aggregation settings:
- Calculation. First select Advanced if you want to enter a specific calculation. The form adjusts to show a text entry box. Enter the expression for the required calculation referencing simple Aggregations:
Math.max(0, aggregation.num_requests - (aggregation.unique_apps * 100))
- Unit. For this example, enter Requests. This will be used as a label for billing to indicate to your customers what they are being charged for.
- Quantity per unit. Enter the quantity by which you want to charge for the measured value. For example, if you want to charge your customers on a per-500 units used basis, enter 500. For the current example, enter 1.
- Rounding. Specifies how you want m3ter to deal with non-integer, that is fractional number, Aggregation values. See Reviewing Aggregation Options for example. Four options:
- None. Default
- Down
- Up
- Nearest. Rounds up to the nearest half: 5.1 is rounded to 5; 5.5 is rounded to 6.
- Note: Also used in conjunction with Quantity per unit setting. Rounds the number of units after the Quantity per unit has been applied. See Reviewing Aggregation Options for example.
- Evaluate null aggregations. Optional setting - enable this if you want to allow null values from the simple Aggregations referenced in the Compound Aggregation to be passed in. Simple Aggregations based on Meter Target Fields where no usage data is available will have null values. Default is to have this disabled:

- Add any required Custom fields to the Compound Aggregation. For more on Custom fields, see Adding and Editing Custom Fields. We strongly recommend reviewing Working with Custom Fields before you create and use Custom fields.
- Select Create compound aggregation. The Compound aggregation details page opens:

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

- Select Yes to confirm the delete action.