---
schema_version: "1"
id: d2d401e446009ce0b6d5a6cda301164f9f70dfccc0ed5a64011c458b355515bc
title: "Example: Analyze Product Cost and Profit Margins with Advanced Account Forecasting and Data Processing Engine"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/aaf_customize_dpe_revenue_metrics.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.aaf_customize_dpe_revenue_metrics.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: ac4a9f1f4d244c7cd167033861900303ff9701b08dfa752fd141ee336a24afca
description: A company wants to analyze the cost and profit margins of their products using account forecasts. However, the predefined measures available with Advanced Account Forecast Fact only help account managers view quantity and revenue-based metrics for their products from orders, opportunities, and sales agreements. Demand planners typically look at the cost of a product across accounts and also the profit margins for a specific account-product combination. Having visibility into the revenue and profit margins for future periods helps them plan their costing and discounting strategies for all accounts. In this example, we’ll see how you can add new measures for advanced account forecasts and use the Data Processing Engine to calculate the values for these custom measures.
products:
  - Manufacturing
release: "264"
---
# Example: Analyze Product Cost and Profit Margins with Advanced Account Forecasting and Data Processing Engine

A company wants to analyze the cost and profit margins of their products using account forecasts. However, the predefined measures available with Advanced Account Forecast Fact only help account managers view quantity and revenue-based metrics for their products from orders, opportunities, and sales agreements. Demand planners typically look at the cost of a product across accounts and also the profit margins for a specific account-product combination. Having visibility into the revenue and profit margins for future periods helps them plan their costing and discounting strategies for all accounts. In this example, we’ll see how you can add new measures for advanced account forecasts and use the Data Processing Engine to calculate the values for these custom measures.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr></tbody></table>

## Business Requirements

Here are the requirements from the demand planners.

- Define the fixed and variable cost of a product in its associated price book. A product can have multiple price books associated with it, each with different fixed and variable costs. A price book is a list of products and their associated prices. Each product and its price is called a price book entry.
- When a product is associated either with a sales agreement or an opportunity, derive the fixed and variable cost of a product from the price book associated with the sales agreement or opportunity.
- View these metrics on the forecast grid:
    - Fixed Cost
    - Variable Cost Per Unit
    - Total Cost
    - Actual Profit
    - Forecasted Profit
    - Forecasted Gross Margin Percentage
    - Actual Gross Margin Percentage
- Aggregate the total variable cost, quantity, and fixed cost of a product for all sales agreement products and opportunity products and group the data by product. Then, divide the total variable cost by the total quantity to get the cost per unit of a product.
- Customize the Data Processing Engine templates to calculate the values for all measures.
- Derive the actual profit and actual gross margin from orders.
- Define unique formulas for the other metrics that update the final values in the forecast grid. The formulas must be applied on the values calculated by the Data Processing Engine.

## Get Started

1. **[Create Custom Fields to Capture Cost and Profit Metrics](https://help.salesforce.com/s/articleView?id=ind.aaf_customize_dpe_revenue_metrics_requirements.htm&release=264.0.0&type=5)**  
    To capture fixed cost and variable cost details, create custom fields on Price Book Entry. Then add those custom fields on the Advanced Account Forecast Fact object so that the data can be written back for each period by the Data Processing Engine job. Additionally, you can add custom fields for other measures that demand planners want to view on the forecast display.
2. **[Add Revenue Measures to a Forecast Set](https://help.salesforce.com/s/articleView?id=ind.aaf_customize_dpe_revenue_metrics_forecast_set.htm&release=264.0.0&type=5)**  
    Define the new cost and profit-based revenue measures in the forecast set that determines the forecast display for accounts. When specifying forecast measures, you can select the measure type, aggregation type, and calculation method.
3. **[Customize the Generate Account Forecast Template](https://help.salesforce.com/s/articleView?id=ind.aaf_customize_dpe_revenue_metrics_definition.htm&release=264.0.0&type=5)**  
    Clone and customize the predefined Data Processing Engine templates available with Advanced Account Forecasting to generate, calculate, rollover, and regenerate forecasts with the new revenue measures. The cloned definitions must be activated after you make the required changes and the definitions are selected for use in the forecast set. You can run the definitions periodically through scheduled flows for all or selected accounts.