The previous topics in this section introduced a variable usage discounting example use case and went on to explain how to create a Discount Vol Rates Lookup Table and a Table Revision to implement this kind of use case. How to add the required Table Revision data values for the example and publish the Table Revision was also explained.
This topic goes on to explain how to complete the set up in your Organization for the example use case. We then submit some sample data against test Accounts to check the implementation is working as expected:
Setting Up a Meter. Create and configure a Meter with a Derived Field calculation that uses a Lookup function referencing the Discount Vol Rates Lookup Table to apply discount rates by country to ingested usage data volumes.
Creating an Aggregation. Target the Meter's Derived Field and use the Aggregation to price Plans attached to Accounts.
Submitting Sample Data and Checking Account Bills. Submit some sample usage data measures for test Accounts and generate sample Bills to check that Accounts in different countries are billed according to the appropriate discounted usage volume measures.
Important! Before you attempt to follow this worked example, please review the earlier topics in this section: Creating and Managing Lookup Tables and Adding Data to, Publishing, and Managing Lookup Table Revisions.
Here's the setup for Vol Data Meter 1 to serve the example discounting usage rate use case:
A Measure Data Field called Gibytes Upload to collect usage volumes.
A Dimension Data Field called Country to collect Account country.
A Discount Volume Derived Field with a calculation that uses a Lookup function referencing the Discount Vol Rates Lookup Table to apply discount rates by country to the Gibytes Upload Data Field usage volumes.
When a usage data measurement is ingested for an Account using the Meter, the example Derived Field calculation takes the value of the Gibytes Upload Data Field and multiplies it by the number value yielded by the Lookup.findNumber() function.
Lookup.findNumber() is a multi-argument function which returns a number value and is of the generalized form:
Lookup.findNumber(<table_code>, <return_field>, <default_value>, <key1>, <key2>, ...)
For the Lookup.findNumber() function used in our Derived Field calculation we have:
Lookup.findNumber("discount_vol_rates", "rate", 1, "country")
This will lookup the number value for the rate field in the published Discount Vol Rates Rev1 Revision of the Discount Vol Rates Lookup Table given the country keyed field, which must be present in the measurement. If no match is found, then a default value of 1 will be used for the rate.
Given the data values we set up for the published Discount Vol Rates Rev1 Revision of the Discount Vol Rates Lookup Table:
If the Meter ingests a usage data measurement where the country is UK, then the rate value returned by the Lookup.findNumber() function will be 0.8.
If the Meter ingests a usage data measurement where the country is US, then the rate value returned by the Lookup.findNumber() function will be 0.9.
Tip: Available Lookup Functions? See Lookup Functions for a summary of available functions.
Here's the detail for a Vol Data Agg1 Aggregation targeting the Discount Volume Derived Field on Vol Data Meter 1:
We can use this Aggregation as a pricing metric to price Plans attached to Accounts. Since it uses a SUM method on the Meter's Discount Volume Derived Field values, we expect that the volume charged for against an Account will be for discounted usage volumes according to the rates by country we have set up for the published version of the Discount Vol Rates Lookup Table.
To check our worked example of a variable discounted usage rate implemented using a Lookup Table, we'll now submit some sample Data to two test Accounts - one based in the UK and one in the US. We can then:
Open Usage Data Explorer (v2) and perform a query to return the usage data submissions that were ingested, and to check the Discount Volume Derived Field values have been calculated correctly.
Run billing for each Account and check they are correctly charged at the appropriate discounted rates by country.
To test Lookup Table example:
1. First create two test Accounts - one based in the UK and one based in the US. For example:
Vol Stored UK Account
Vol Stored UK Account
See Creating and Managing Accounts.
2. Create a test Product, create a Product Plan Template and a Plan based on the Plan Template that uses monthly billing in arrears with US Dollars billing currency.
3. Then use the Vol Data Agg1 Aggregation to price the Plan using a single price tier for a flat charge rate of 1 USD per GigaByte of storage used.
4. Attach the priced Plan to each test Account.
5. Open each Account, and submit a single sample usage data measurement of 1000 GB using Vol Data Meter 1 for a given month's billing period. For example:
6. To check how the usage data measurements were ingested, you can now open Usage Data Explorer (v2) and submit a Query for the Vol Data Meter 1 and a Custom time period for the date you made the usage submissions:
In the Results row table returned for the Query, we see that for each usage measurement submitted to the two Accounts, the Discount Volume Derived Field value has been correctly calculated for the Gibytes Upload raw volume and the rate values by Country we added to the published Discount Vol Rates Rev1 Revision of the Discount Vol Rates Lookup Table.
7. Lastly, run billing for each Account for the relevant month's billing period. For the current example and having made the single 1000 GB submissions to each Account in July, we'll run billing to check the usage charge for the August 1st bills:
For the Vol Stored UK Account:
For the Vol Stored US Account:
As expected, each Account Bill shows that the number of units charged has been correctly adjusted for the rate by country set using the published Discount Vol Rates Rev1 Revision of the Discount Vol Rates Lookup Table.
We can see that by using a Lookup function referencing the Discount Vol Rates in our Meter Derived Field calculation, to change these discounted usage volume rates for the next month's billing period we need only:
Duplicate the published Discount Vol Rates Rev1 Revision to create a new draft Revision called Discount Vol Rates Rev2.
Add updated data values to the new draft Revision - for example:
country = UK, rate = 0.85
country = US, rate = 0.95
Publish the new Revision.
In addition, if an end customer Account located in a third country was added, we could also ensure that the next published Revision for the Lookup Table our Derived Field calculation references has data field values added for rate and country to cover the discounted usage rate we want to apply to that third country.
Next: Lookup Functions
Login to the Support portal for additional help and to send questions to our Support team.