For many usage-based pricing use cases, you can use Compound Aggregation calculations to reference one or more simple Aggregations and satisfy and resolve the most complex pricing requirements - they're the complexity crunchers! By exploiting the powerful m3ter Calculation Engine, there's virtually no limit to the flexibility they give you for defining your precise pricing metrics. And it's worth noting that you can build a Compound Aggregation that does not reference a single simple Aggregation, should that help by giving you a pricing metric that is not determined by metered usage alone, but is nevertheless essential for your complex, mixed-pricing use case.
This topic gives some examples of Compound Aggregation calculations as guidance on how to work with them to achieve the precise pricing you need for products and services. In addition to concrete examples, the second section in this topic:
Links you out to a topic on supported syntax and functions for your Compound Aggregation calculations.
Explains how to reference simple Aggregation values and Custom Fields in your Compound Aggregation calculations.
Important! Compound Aggregation Calculations Use Base Values of Simple Aggregations. If a simple Aggregation referenced by a Compound Aggregation has a Quantity per unit defined for pricing and billing purposes or a Rounding defined, then these will not be factored into the value used by the calculation. For example, if a simple Aggregation referenced has a base value of 100 and has a Quantity per unit set at 10, any Compound Aggregation calculation that references it will use the base value of 100 and not 10.
Suppose your production environment contains three Meters each collecting usage data for time duration measures in seconds. You have set up simple Aggregations to SUM each of these Meter Data Fields:
Watch duration: watch_seconds
Testing duration: test_seconds
Live duration: live_seconds
However, you want to set up pricing on a Product that charges your end-customers on the basis of their combined usage duration per billing period across all three simple Aggregations, and to charge by the minute, not by the second.
To satisfy this pricing use-case, you can use a Compound Aggregation that adds together the simple Aggregation values and then divides the total by 60:
Calculation:
aggregation.watch_seconds
+aggregation.test_seconds
+aggregation.live_seconds
/60
Suppose you a run a cloud service company which offers end customers computing capabilities. You'll set up pricing for products to charge on a monthly basis with a usage measure of total Gigabytes-per second used per month together with a monthly standing charge. However, as a sign-up bonus you want to offer credits to new customers for the first six months whereby they receive a credit rebate each month if they log into their accounts fewer than 20 times that month per user - roughly, that is, at least once for every user they have for every working day in a month. For each time fewer than the expected number of user logins, they'll receive a $10 credit rebate on their Bill. To implement this and incorporate it into your pricing schema, you therefore need a way to count the number of user logins fewer than 20 each month for each user registered under a customer Account. This might seem like a difficult use case to satisfy as part of your overall UBP model, but by using the following Compound Aggregation in m3ter you can quickly implement it.
First we set up two simple Aggregations:
The total number of registered users under the end customer Account at the end of each monthly billing period: number_regusers
The total actual number of logins recorded for all the registered users on the Account in a given month: total_reguserlogins
We can then create a Compound Aggregation that references these two simple Aggregations:
Calculation:
Math.max(20*aggregation.number_regusers - aggregation.total_reguserlogins,0)
This calculation yields the required count of the number of fewer than expected registered user logins in the month:
We take the number of registered users for the Account and multiply this by 20 (using this as a rough average of the number of working days per month) to generate an expected number of user logins (one login per user per working day).
We then subtract the actual number of user logins from the number of expected user logins to generate a number of credits to rebate the Account that month.
We use a Math.max()
function to give a zero (no credits) if the number of actual user logins exceeds the number of expected logins for that Account.
Tip: Negative Pricing! Note that since we suppose there will be positive charges applied under the pricing applied for usage and standing charge, you can set the pricing configured using this Compound Aggregation as a negative pricing (-$10 per unit) to have it show as a credit on the monthly Bills.
Suppose you a run a cloud service company which offers financial institutions products designed to prevent them becoming victims of online fraudulent behavior:
A service to catch and block suspect attempts to gain access to their online services - either by login attempts that use bogus accounts or login attempts using registered accounts that show suspicious traits. In either case, the login attempt is blocked and the attempt logged. You market this under the product name: "Account Secure".
A service that checks payments submitted by legitimate account holders using credit cards. If the payment details are not validated, the payment attempt is rejected and logged. You market this second service under the product name: "Payments Check".
Your pricing schema for both these services will be similar:
For both services, you will charge on the basis of the number of events where your protection service has been activated during the agreed billing period:
For customers who take the Account Secure product: a count of the number of events where your service activated, identified something suspicious, and blocked an attempt at login.
For customers who take the Payment Check product, a count of the number of events where your service was activated, checked submitted payment details and, finding those details to be false, rejected the payment submission.
In addition for both products, you differentiate within the total count of these events by recording the country of origin of the online users, which is useful when reviewing and analyzing bogus login attempts and attempts to pay using false credit card details. For the sake of the example, we suppose your customers operate across these three countries - the United States, Canada, and the United Kingdom.
To price each product, we can now use a Compound Aggregation that simply adds the simple Aggregations that count events across the three countries of operation:
Account Secure Product: we create three simple Aggregations to count bogus login attempts for each country:
account_uslogins
account_canlogins
account_uklogins
We can now create a Compound Aggregation for this product, which adds together the values of these three simple Aggregations:
Calculation:
aggregation.account_uslogins + aggregation.account_canlogins + aggregation.account_uklogins
This is now available to price Plans for your Account Secure product and for charging end customer Accounts that consume this product.
Payment Check: we create three simple Aggregations to count payments that tried to use false credit card details for each country:
payment_ussubmit
payment_cansubmit
payment_uksubmit
We can now create a Compound Aggregation for this product, which adds together the values of these three simple Aggregations:
Calculation:
aggregation.payment_ussubmits + aggregation.payment_cansubmits + aggregation.payment_uksubmits
This is now available to price Plans for your Payment Check product and for charging end customer Accounts that consume this product.
However, a new customer approaches you and wants to take both products as a combined contract and you'll likely want to offer them discounted rates across both products. For this use case, we can now set up a global Compound Aggregation - one that is not tied to a specific product - and adds together both sets of simple Aggregations we used for pricing a specific product, and therefore creates a Compound Aggregation that forms a cross-product bundle:
Calculation:
aggregation.account_uslogins + aggregation.account_canlogins + aggregation.account_uklogins + aggregation.payment_ussubmits + aggregation.payment_cansubmits + aggregation.payment_uksubmits
This is now available to price Plans for your product bundle offering and for charging end customer Accounts that consume both products under the bundle.
This section explains the syntax for referencing simple Aggregation values and Custom Fields in your Compound Aggregation calculations.
For details of the syntax and supported functions and operators in calculations, see Calculations Syntax and Supported Functions/Operators.
You can reference the resultant values of simple Aggregations in a Compound Aggregation calculation using a simple Aggregation's Code. The general format is:
aggregation.<aggregationCode>
You can reference Segmented Aggregations in a Compound Aggregation. The segments defined for the referenced Aggregations that are made available the Compound Aggregation depends on whether it references one or many Segmented Aggregations - see Compound Aggregations - Segments Available.
The simple Aggregations you can reference when you create a Product-specific Compound Aggregation or a Global Compound Aggregation are the same:
The calculation can reference all simple Aggregations – any Product-specific and any Global simple Aggregations.
When referencing Custom Fields in your Compound Aggregation calculations, you can use the following format:
organization.<fieldName>
meter.<fieldName>
product.<fieldName>
account.<fieldName>
accountPlan.<fieldName>
plan.<fieldName>
planTemplate.<fieldName>
Tip: More on Custom Fields? Note that Meter is an exception in that the default value defined at Organizational level is always used. See Adding and Editing Custom Fields and Working with Custom Fields for more details.
Next: Segmented Aggregations
Login to the Support portal for additional help and to send questions to our Support team.