---
schema_version: "1"
id: fe3f13f2b66822a0c1e41fff9a03fa3f167553eb088d08744060b85f33ba200e
title: Accumulated Variables in Salesforce Spiff
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_accumulated_variable.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_accumulated_variable.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: ab4e509a1c5230e7f0c8e1fe827556a923ec34b0cb911f6e43ac65a24df6fb6f
description: An accumulated variable is like a running total, where Salesforce Spiff sums a field or value within a sorted data filter and returns a cumulative value up to a current record. An accumulated variable helps you quickly sum multiple values with fewer calculations.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# Accumulated Variables in Salesforce Spiff

An accumulated variable is like a running total, where Salesforce Spiff sums a field or value within a sorted data filter and returns a cumulative value up to a current record. An accumulated variable helps you quickly sum multiple values with fewer calculations.

### 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: both Salesforce Classic (not available in all orgs) and 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><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available for an additional cost in: <strong>Professional</strong> Edition with Web Services API Enabled</td></tr></tbody></table>

For example, consider a data filter that returns five deals.

 
| Deal | Amount |
| --- | --- |
| Deal 1 | $500 |
| Deal 2 | $1,800 |
| Deal 3 | $750 |
| Deal 4 | $865 |
| Deal 5 | $1,350 |

If you're maintaining a running total of these amounts, each successive deal represents a different calculation. For a manual sum, each new deal increases the number of values to include in the sum calculation. With an accumulated variable, each new deal is a calculation of only the previous total plus the new value.

   
| Deal | Amount | Running Total with Manual Sum | Running Total with Accumulated Variable |
| --- | --- | --- | --- |
| Deal 1 | $500 | $500 | $500 |
| Deal 2 | $1,800 | $500 + $1,800 = $2,300 | $500 + $1,800 = $2,300 |
| Deal 3 | $750 | $500 + $1,800 + $750 = $3,050 | $2,300 + $750 = $3,050 |
| Deal 4 | $865 | $500 + $1,800 + $750 + $865= $3,915 | $3,050 + $865 = $3,915 |
| Deal 5 | $1,350 | $500 + $1,800 + $750 + $865 + $1,350= $5,265 | $3,915 + $1,350 = $5,265 |

For best performance, use the fewest calculations. Calculated fields compute one time for every record, and summary calculations compute one time for every statement. Consider how the calculation time scales over thousands of records. If you have 10,000 deals, the manual sum requires 50,005,000 calculations, but the accumulated variable requires only 19,999 calculations.

Keep these considerations in mind when working with accumulated variables.

- Pair an accumulated variable with the `mpercent()` and `mamount()` functions, which require an initial value. For example, if you're accumulating ARR, you can create a calculated field such as Prior\_YTD\_ARR that subtracts the current deal's ARR from the accumulated total.
- A common error with accumulated variables occurs when a record in the rule's data filter is missing from the accumulated variable's data filter. To identify and troubleshoot errors, create test data filters that include all the components needed for accumulation. Pair these test data filters so you can identify which subfilters are excluding the missing records.
- An accumulated variable can’t sort null values. For example, if some deals don't have a close date and you want to group them together at the start or end of sorted results, you must create a calculated field. To make sure that deals are sorted last, use a future date. You can also manipulate the sorting order with calculated fields.
- To improve performance, turn off trace.

- **[Turn on an Accumulated Variable in Salesforce Spiff](https://help.salesforce.com/s/articleView?id=sales.spiff_accumulated_variable_enable.htm&release=264.0.0&type=5)**  
    Analyze sales data and identify trends and patterns with accumulated variables.
- **[Examples of Manual Accumulated Variables with the Let Function](https://help.salesforce.com/s/articleView?id=sales.spiff_accumulated_variable_let.htm&release=264.0.0&type=5)**  
    Sometimes, an accumulated variable in Salesforce Spiff can't calculate an amount, so you must manually create accumulated variables by using the `let()` function.

#### See Also

- [Accumulated Variables in Accelerator Functions](https://help.salesforce.com/s/articleView?id=sales.spiff_accelerator_accumulated_variable.htm&release=264.0.0&type=5 "An accumulated variable is often used with the initial_value argument in the mamount() and mpercent() accelerator functions in Salesforce Spiff.")