---
schema_version: "1"
id: a2b5dd3f9684f69765c0691cab229ee94c9d077b7cd023ac0e72d80b59679df8
title: Set Up Dynamic Usage Quantity
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_set_up_dynamic_usage_quantity.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_set_up_dynamic_usage_quantity.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 9ece64158ae45131113f0a2d43f6bc56a31d8f35919f13d60ffd723c6182f00f
description: You can source the estimated usage quantity of a service at a service point, premises, subscriber, or service account from various custom fields. A calculation matrix identifies the custom field based on different criteria. You can configure the system to calculate usage pricing for a service based on the usage quantity recorded in the custom field identified in the calculation matrix.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# Set Up Dynamic Usage Quantity

You can source the estimated usage quantity of a service at a service point, premises, subscriber, or service account from various custom fields. A calculation matrix identifies the custom field based on different criteria. You can configure the system to calculate usage pricing for a service based on the usage quantity recorded in the custom field identified in the calculation matrix.  

For example, you can record the average quarterly usage of electricity at a service point in one custom field and the average annual usage of electricity in another custom field. You can then set up a calculation matrix to specify which custom field should be used to source the usage quantity in usage pricing calculations at runtime.

Set up dynamic sourcing of usage quantity at a service point.

1. Create a calculation matrix.
2. Create a calculation procedure.
3. Select the calculation procedure in the CPQ Configuration set up.

## Create a Calculation Matrix for Dynamic Usage Quantity

You can set usage quantity for every line item of the service quotes or order under a group using the calculation matrix.

The calculation matrix consists of input and output columns. The input column identifies the line item for which usage quantity is required. The output column identifies the object field used to pick the usage data.

1. Define the input columns:
    1. Add an input column to identify the Cart line items, such as products or services, for which the usage quantity is required. For example, add an input column Product Code to identify the products.
    2. Add an input column to identify the line item attribute for which the usage quantity is required. For example, add an input column Attribute Code to specify the product line item attribute for which usage quantity needs to be added.
2. Define the output columns to identify the source from where the usage quantity is fetched.
    1. Add an output column named ServiceFieldAPIName. The value of this column is used to pick up usage data from objects such as premises, service-point, subscriber, or service account.
    2. Optionally, add another output column named Target. The value of this column identifies the field where the usage data value is copied in the Cart line items. You must name the output columns ServiceFieldAPIName and Target for the calculation matrix to work.
        
        - UsageOnly - The usage data is copied to the usage quantity field of the Cart line item.
        - AttributeOnly - The usage data is copied to the attribute field of the Cart line item.
        - AttributeAndUsage - The usage data is copied to both the usage quantity and attribute fields of the Cart line item.
    3. Create the calculation matrix after you have defined the input and output columns.
3. On the App Launcher, search for **Vlocity Calculation Matrices**, and open it.
4. Click **New**.
5. In the **Calculation Matrix Name** field, enter a name for the calculation matrix, for example, DynamicUsageQuantityMatrix.
6. Click **Save**.
7. On the Vlocity Calculation Matrix page, click the **Related** tab.
8. Click **View all** and select the calculation matrix version for which you want to create the matrix data.
    
    The **Details** tab is displayed.
9. In the **Table** section, click **Add Header**. Enter the following details:
    1. **Name**: Enter a name for the column header, for example, Average Monthly Consumption.
    2. **Header type**: Defines the column mapping. Select **Input** if the column obtains data for the calculation. Select **Output** if the column returns data from the calculation.
    3. **Data Type**: Select a data type, for example, Number.
    4. **Matrix Display Order**: Specify a number, for example, 2. It defines the sequence in which the column is displayed.
    5. Add more Header columns as required.
    6. Click **Edit Data** and enter appropriate data in the matrix.
    7. Click **Save Data**.
    8. Create a Calculation Procedure for Dynamic Usage Quantity.

## Create a Calculation Procedure for Dynamic Usage Quantity

After creating a calculation matrix, create a calculation procedure to set up dynamic sourcing of usage quantity at a service point.

1. From the App Launcher, open Vlocity Calculation Procedures.
2. Click **New**.
3. Select the **Declarative** record type and click **Next**.
4. Enter a name for the calculation procedure, for example, Usage Quantity Pricing Procedure.
5. Click **Save**.
6. On the Vlocity Calculation Procedure page, click the **Related** tab.
7. Click **View all** and select the calculation procedure that you created.
8. (Optional) Click and expand the **Preprocessor Class Name** section.
9. (Optional) In the **Enter your pre-processor Apex class name below** box, enter a pre-processor Apex class name, for example, UsageConfigPreProcessor.
10. Click and expand the **Calculation Steps** section.
    1. Click **Add Step**.
    2. Select **Matrix Lookup**.
    3. Enter the name of the calculation matrix you created, for example, DynamicUsageQuantityMatrix.
    4. Select **Include in Calculation Output** on the right.
        
        ![Calculation Steps](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-comms_media_energy_managed-264-0-0-production-enus/ff4079f6-a384-475c-b863-578bbbb0ef9b/resources-product/images/screenshot_2020_01_23_at_6_17_08_pm.png)
11. Go to the Calculation Setup section. Click the pencil icon and select **Enabled**.
12. Click **Save**.
13. Configure CPQ Configuration Setup for Usage Quantity.

## Configure CPQ Configuration Setup for Usage Quantity

After creating a calculation procedure, complete the CPQ setup for usage quantity to finish dynamic sourcing of usage quantity at a service point.

1. From the App Launcher, search for Vlocity CMT Administration, and open it.
2. Click **CPQ Configuration Setup** under Custom Settings.
    
    The CPQ Configuration Setup page opens.
3. Scroll to the end of the page and click **Add**.
4. In the Name column, enter UsageQuantityCalculationProcedureName.
5. In the Setup Value column, enter the name of the calculation procedure you created in the previous task, for example, Usage Quantity Calculation Procedure.
    
    ![Usage Quantity Calculation Procedure](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-comms_media_energy_managed-264-0-0-production-enus/ff4079f6-a384-475c-b863-578bbbb0ef9b/resources-product/images/screenshot_2020_01_28_at_8_24_51_pm.png)
6. Click **Save**.