Example: Referencing Variables

Depending on the scope of a KPI, you can reference a promotion or a tactic variable in a formula.

Required Editions

Available in: Lightning Experience

Available in: Enterprise and Unlimited Editions where Consumer Goods Cloud is enabled

If the scope of a KPI is Promotion, Promotion Tactic, or Payment Tactic, the KPI can reference the Promotion object. Define fields of the Promotion object in the Promotion__c.CalculationVariables fieldset. For example, if you have a Phase__c field, then you can add the Promotion object as the input parameter in a formula.

Promotion as Variable
Promotion as Variable
{
    "name": "myExampleKPI",
    “scope”: “promotion”,
    "type": "calculated",
    "formula": "(MyKpi1, MyKpi2, Promotion) => { if Promotion.phase === 'Planning') return MyKpi1; else return MyKpi2}",
}

(MyKpi1, MyKpi2, Promotion) => { if Promotion.phase === 'Planning') returns MyKpi1; else return MyKpi2}

If the scope of a KPI is Promotion Tactic or Payment Tactic, you can use the Tactic object as the input parameter in a formula. Define fields of the Tactic object in the Tactic__c.CalculationVariables fieldset.

Tactic as Variable
Tactic as Variable
{
    "name": "myReferencedKPI",
    "type": "read",
    "aggregation": {
        "rule": "sum"
    },
    "totalcalculation": {
        "rule": "sum"
    },
    ...
}, {
    "name": "myExampleKPI",
    “scope”: “promotiontactic”,
    "type": "calculated",
    "formula": "(myReferencedKPI, Tactic) => { return myReferencedKPI / Tactic.lift;}",
    "aggregation": {
        "rule": "sum"
    },
    "totalcalculation": {
        "rule": "sum"
    },
    ...
}

Here are the values for the tactic variable:

  • amount: 3500
  • lift: 7.5
  • datefrom: 1493210282611

Here’s how the KPIs are calculated.

KPI Aggregation Level Total Period1 Period2 Period3
myReferencedKPI Promotion 930 130 140 660
myReferencedKPI Tactic 1 750 100 50 600
myReferencedKPI Product 1 500 100 0 400
myReferencedKPI Product 2 250 null 50 200
myReferencedKPI Tactic 2 330 90 120 120
myReferencedKPI Product 1 180 30 90 60
myReferencedKPI Product 3 150 60 30 60
 
myExampleKPI Promotion 7.5 1 0.5 6
myExampleKPI Tactic 1 1 0.1333 0.0666 0.8
myExampleKPI Product 1 0.6666 0.1333 0 0.5333
myExampleKPI Product 2 0.3333 0 0.0666 0.2666
myExampleKPI Tactic 2 1 0.2727 0.3636 03636
myExampleKPI Product 1 0.5454 0.0909 0.2727 0.1818
myExampleKPI Product 3 0.4545 0.1818 0.0909 0.1818