sumif

Calculates a total value from a list of numbers in Salesforce Spiff, but only for records that satisfy a specified condition.

Required Editions

Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Enterprise, Unlimited, and Developer Editions
Available for an additional cost in: Professional Edition with Web Services API Enabled

Syntax

sumif(filter, condition, column_or_field)

Arguments

Argument Required? Description
filter Required The data filter with a list of records to sum. Enclose a list in brackets with comma-separated values.
condition Required An expression that specifies a condition that must be true for the function to calculate a sum. To specify multiple conditions, use AND or OR operators.
column_or_field Required if summing a data filter An expression that specifies the column or field from the filter's records that you want to sum.

Considerations

  • This function returns the same values as the standard sum() function that uses an optional condition. But, this function better describes the result of the formula that uses it, which is useful for internal accountability.
  • You can use other formulas for the condition or column_or_field arguments, but only if the formulas apply to the same object as filter.

Example

Sum the value of the ARR__c field, but only if the ARR__c value is greater than $25,000.

=sumif(ClosedInPeriod, ARR__c > 25000, ARR__c)

Sum the value of the ARR__c field, but only if the ARR__c value is greater than $25,000 and less than $50,000.

=sum(ClosedInPeriod, ARR__c > 25000 AND ARR__c < 50000, ARR__c)