How Can I Group Transactions To Create Reward Groups (Advanced)?

How Can I Group Transactions To Create Reward Groups (Advanced)?


Sometimes, you must group credited transactions to calculate payouts.

Grouped Payout Example 
Consider a commission structure whose payout is based on a count of credited transactions per customer:
  1. Group credited transactions by customer
  2. Determine the transaction count per customer
  3. If a customer has 1 transactions, pay $1 per customer
  4. If a customer has 2 transactions, pay $3 per customer
  5. If a customer has 3+ transactions, pay $5 per customer

You could create a single global reward with a complex grouping query:


In the example above:
  1. A subquery groups credited transactions by customer and produce a count per customer
    1. SELECT COUNT(*) AS TransactionCount FROM Transactions GROUP BY <customer> AS T
  2. A parent query convert each of the sub-query's per-customer counts into payouts ($1, $3, or $5) and sum them
    1. SELECT SUM(CASE WHEN...END) FROM <subquery T>
  3. However, only 1 reward is generated, so visibility is limited, and the logic is rather complex
Info
There are other ways to write the query above, for example using PARTITION BY.

Do You Need Reward Groups?
In most cases, it's sufficient to use pre-canned rewards such as "% of Revenue", "% of Profit", or "Cash Reward". Those options do not require formulas.



However, if you need to group transactions to calculate payouts, the above may not suffice. As explained above, you may be able to use a global reward and a more complex query, but this may not be the best solution.

To generate one reward per group, use reward groups.

Defining Reward Groups
First, review this article about formulas to understand how they work, and which constructs are available.

Next, specify how you want to group credited transactions:
  • Edit your plan
  • Click on the "Limits" tab
  • Enter a filtering formula to store each transaction's group
    • Call SetRewardGroup() to set the group

For example, you could group by a single field such as the customer name:
 

Or you could group by a combination of fields:


Next, add a single reward:
  • Edit your plan
  • Click on the "Incentives" tab
  • Add a global reward
  • Enter a global reward formula to calculate the payout for each group



Assuming the reward is activated by attainment, a separate reward will be created for each group. Your reward logic only needs to focus on a single group (ex: a single customer). This makes the logic easier as you can see above. Your logic will be invoked multiple times (one time per applicable group). Multiple rewards will be generated (one time per applicable group).

For example, if you grouped by customer, your calculation will show one reward per group:


 

Key Mechanisms
To recap:
  1. Call SetRewardGroup() to define groups
    1. Typically in a filtering formula
  2. Add a reward of the following type
    1. A global reward
    2. A per-transaction reward
    3. A % of revenue reward, with "per-transaction" checked
    4. A % of profit reward, with "per-transaction" checked
    5. A % of score reward, with "per-transaction" checked
    6. A % of custom reward, with "per-transaction" checked
  3. If triggered, the reward will be activated one time per applicable group
    1. Write logic with the assumption that only transactions belonging to the group will be assigned
Idea
Other types of rewards, which are NOT per-transaction (ex: prizes, announcements, badges, etc.) are NOT affected by groups, and will only be activated once.

Notes
Reward groups do NOT affect attainment / tier activation. Attainment / tier activation is still based on all credited transactions. However, when rewards are activated within a tier, a further segmentation process is applied to transactions to trigger the reward multiple times (once per group).

Incentive Dashboards
Like calculations, incentive dashboards will show one reward per applicable group: