---
schema_version: "1"
id: e690f04273f953db84fde8771105d9b4151072cbf115d121c0907d1a0210609f
title: "Example: Referencing Other KPIs of the Same Granularity"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/concept_refrencing_other_kpis_same_granularity.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.concept_refrencing_other_kpis_same_granularity.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 898c3f5d4597f5db988fb17b8a5dc93c5abee02a3ede4bf49e1125b1ee6bc522
description: You can specify other KPIs as an input parameter in a formula.
products:
  - Consumer Goods
release: "264"
---
# Example: Referencing Other KPIs of the Same Granularity

You can specify other KPIs as an input parameter in a formula.

### 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;">
            <p>Available in: Lightning Experience</p>
            <p style="margin-bottom:0;">Available in: <strong>Enterprise</strong> and <strong>Unlimited</strong> Editions where Consumer Goods
              Cloud is enabled</p>
          </td>

        </tr>
      </tbody>
    </table>

![Calculating a KPI When Referencing Another KPI](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-consumer_goods_trade_promo-264-0-0-production-enus/169b0c8b-175d-4639-bf96-610b16824687/images/icon_example.png)

Calculating a KPI When Referencing Another KPI

Here are two KPIs:

![Sample KPI definition](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-consumer_goods_trade_promo-264-0-0-production-enus/169b0c8b-175d-4639-bf96-610b16824687/consumer_goods_trade_promo/images/kpi_definition_myReferencedKPI.png)

![Sample KPI definition](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-consumer_goods_trade_promo-264-0-0-production-enus/169b0c8b-175d-4639-bf96-610b16824687/consumer_goods_trade_promo/images/kpi_definition_myExampleKPI.png)

My Referenced KPI is a read KPI with a min aggregation rule and a max total calculation rule. The My Example KPI is the main KPI and is calculated by dividing My Referenced KPI by 100, as defined in the formula field. The table shows sample data for My Example KPI and the expected calculation results for My Referenced KPI.

     
| KPI | Aggregation Level | Total | Week 1 | Week 2 | Week 3 |
| --- | --- | --- | --- | --- | --- |
| My Referenced | Promotion | 200 | 100 | 0 | 200 |
| My Referenced | Product 1 | 400 | 100 | 0 | 400 |
| My Referenced | Product 2 | 200 | Null | 50 | 200 |
| My Example | Promotion | 7.5 | 1 | 0.5 | 6 |
| My Example | Product 1 | 5 | 1 | 0 | 4 |
| My Example | Product 2 | 2.5 | 0 | 0.5 | 2 |

The calculation occurs in this order.

- Read the values of My Referenced KPI at the lowest level of granularity. For this example, it’s the Product 1 and Product 2 level.
- For calculating the value of My Example KPI, execute the formula at the lowest granularity for each period.
- Calculate total values of My Example KPI based of these rules:
    - Product total based on the Total Calculation rule
    - Period total based on the Aggregation rule
    - Promotion total based on the Total Calculation rule

In this example, the input KPI’s Aggregation and Total Calculation rules don’t influence the calculation result of the second KPI. The calculation result of the second KPI is influenced by its own Aggregation and Total Calculation rules.

![Using the Shipment Profile to Distribute Promotion Volume](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-consumer_goods_trade_promo-264-0-0-production-enus/169b0c8b-175d-4639-bf96-610b16824687/images/icon_example.png)

Using the Shipment Profile to Distribute Promotion Volume

To use the shipment profile for distributing promotion volume, calculate the value for each subperiod to ensure that the volume is correctly distributed among the subperiods, and then correctly shown per week.

   
| KPI or Product Dimension | Total | Week 1 | Week 2 |
| --- | --- | --- | --- |
| Planned Base Volume | 5429 | 2715 | 2714 |
| Promotion Volume | 20000 | 10000 | 10000 |
| Shipment Profile | 100.00 | 70.00 | 30.00 |
| Incremental Volume | 14571 | 10200 | 4371 |
| Lump Sum Amount | 15000 | 7500 | 7500 |

This formula distributes the incremental volume.

```
(PromotionVolume, PromotionVolume$Product$Total, PlanBaseVolume,
PlanBaseVolume$Product$Total, ShipmentProfile, Promotion, Period,
Subperiod) => {
if (PromotionVolume !== 0 && PromotionVolume !== undefined) {
const msPerDay = 86400000;
let firstDayOfWeek = Period.datefrom > Promotion.datefrom ? Period.
datefrom : Promotion.datefrom;
let lastDayOfWeek = Period.datethru < Promotion.datethru ? Period.
datethru : Promotion.datethru;
let lengthOfWeek = (lastDayOfWeek - firstDayOfWeek) / msPerDay + 1;
let lengthOfSubperiod = (Subperiod.datethru - Subperiod.datefrom) / msPer-
Day + 1;
return (PromotionVolume$Product$Total - PlanBaseVolume$Product$Total) *
(ShipmentProfile / 100) * (lengthOfSubperiod / lengthOfWeek);
}
return undefined;
}
```