You can use apex triggers to populate a custom metric on the forecast grid. A custom metric is a field
that you can add to the Account Product Forecast (APF) or Account Product Period Forecast (APPF)
objects to display additional information on the forecast grid. For example, you can create a custom
metric to show the profit margin or the cost of goods sold for each product. To populate a custom
metric, you need to write an apex trigger on the APF or APPF object that calculates the value of the
custom metric based on the data in the record. You can use the standard or custom fields in the APF
or APPF object as inputs for the calculation. For example, you can use the Planned Quantity, Planned
Revenue, and Product Cost fields to calculate the profit margin. You can also use the fields from the
related objects, such as the Account, Product, or Sales Agreement, by using the relationship queries.
For example, you can use the Account Name or the Sales Agreement Status fields to filter the records
for the calculation. After writing the apex trigger, you need to deploy it to your org and activate it.
Then, you can add the custom metric field to the forecast grid layout and see the values populated on
the grid. Reference: Create Custom Metrics for Account Forecasts, Apex Developer
Guide, Relationship Queries