---
schema_version: "1"
id: c28f34f90c1cff656739e7bb671c011b5f3dbba7b31212163cd69ef1dc3aca27
title: Salesforce Spiff Function Reference
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: eadcca5f25f09ed075236281c6cc4a1958fd511fc6d02f9b351b40e78d7a58cc
description: Each function in Salesforce Spiff requires specific syntax and arguments.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# Salesforce Spiff Function Reference

Each function in Salesforce Spiff requires specific syntax and arguments.

### 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>

- **[all?](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_all.htm&release=264.0.0&type=5)**  
    Checks whether every record in a data filter or datasheet in Salesforce Spiff satisfies one or more conditions. This function returns `true` when the condition is satisfied. This function is the opposite of the `any?` function.
- **[amount\_from](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_amount_from.htm&release=264.0.0&type=5)**  
    Returns a commission amount for a specific payout rule or the total commission amount from a previous statement period in Salesforce Spiff. A commission plan that pays year-to-date totals and subtracts previous earnings can use this function to reference and subtract commission amounts.
- **[amounts\_from](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_amounts_from.htm&release=264.0.0&type=5)**  
    Returns a sum of commission amounts for specific payout rules or total commission amounts from previous statement periods in Salesforce Spiff. This function is similar to `amount_from()` but requires a date range instead of a specific date.
- **[beginning\_of\_day](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_day.htm&release=264.0.0&type=5)**  
    Returns the first second for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DDT:hour:minute:second:millsecond, plus or minus the hours and minutes away from Coordinated Universal Time (UTC).
- **[beginning\_of\_fiscal\_quarter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_fiscal_quarter.htm&release=264.0.0&type=5)**  
    Returns the first day of the fiscal quarter for a specific date or time in Salesforce Spiff. The return format is YYYY-MM-DD. If you haven't specified fiscal year dates in Spiff, this function falls back to a standard calendar year.
- **[beginning\_of\_fiscal\_year](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_fiscal_year.htm&release=264.0.0&type=5)**  
    Returns the first day of the fiscal year for a specific date or time in Salesforce Spiff. The return format is YYYY-MM-DD. If you haven't specified fiscal year dates in Spiff, this function falls back to a standard calendar year.
- **[beginning\_of\_month](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_month.htm&release=264.0.0&type=5)**  
    Returns the first day of the month for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD.
- **[beginning\_of\_period](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_period.htm&release=264.0.0&type=5)**  
    Returns the first day of the statement period for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD.
- **[beginning\_of\_quarter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_quarter.htm&release=264.0.0&type=5)**  
    Returns the first day of the quarter for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD. If you've specified fiscal year dates that are different from standard calendar dates, use the `beginning_of_fiscal_quarter()` function instead.
- **[beginning\_of\_year](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_beginning_of_year.htm&release=264.0.0&type=5)**  
    Returns the first day of the year for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD. If you've specified fiscal year dates that are different from standard calendar dates, use the `beginning_of_fiscal_year()` function instead.
- **[end\_of\_day](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_day.htm&release=264.0.0&type=5)**  
    Returns the last second for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DDT:hour:minute:second:millsecond, plus or minus the hours and minutes away from Coordinated Universal Time (UTC).
- **[end\_of\_fiscal\_quarter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_fiscal_quarter.htm&release=264.0.0&type=5)**  
    Returns the last day of the fiscal quarter for a specific date or time in Salesforce Spiff. The return format is YYYY-MM-DD. If you haven't specified fiscal year dates in Spiff, this function falls back to a standard calendar year.
- **[end\_of\_fiscal\_year](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_fiscal_year.htm&release=264.0.0&type=5)**  
    Returns the last day of the fiscal year for a specific date or time in Salesforce Spiff. The return format is YYYY-MM-DD. If you haven't specified fiscal year dates in Spiff, this function falls back to a standard calendar year.
- **[end\_of\_month](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_month.htm&release=264.0.0&type=5)**  
    Returns the last day of the month for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD.
- **[end\_of\_period](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_period.htm&release=264.0.0&type=5)**  
    Returns the last day of the statement period for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD.
- **[end\_of\_quarter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_quarter.htm&release=264.0.0&type=5)**  
    Returns the last day of the quarter for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD. If you've specified fiscal year dates that are different from standard calendar dates, use the `end_of_fiscal_quarter()` function instead.
- **[end\_of\_year](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_end_of_year.htm&release=264.0.0&type=5)**  
    Returns the last day of the year for a specific date or time value in Salesforce Spiff. The return format is YYYY-MM-DD. If you've specified fiscal year dates that are different from standard calendar dates, use the `end_of_fiscal_year()` function instead.
- **[choose](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_choose.htm&release=264.0.0&type=5)**  
    Returns a value from a list based on a specified index in Salesforce Spiff. List values in Spiff aren't sorted by any default order. To make sure that you select the appropriate value, combine this function with `sort()` so that you sort the list values before you select a specific index.
- **[contains](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_contains.htm&release=264.0.0&type=5)**  
    Checks whether a string or list includes a specified value in Salesforce Spiff. This function returns `true` or `false`.
- **[count](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_count.htm&release=264.0.0&type=5)**  
    Returns the total number of items in a list or data filter in Salesforce Spiff.
- **[currency](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_currency.htm&release=264.0.0&type=5)**  
    Converts a number of string into a specified currency in Salesforce Spiff.
- **[date](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_date.htm&release=264.0.0&type=5)**  
    Converts a string into a Date data type in Salesforce Spiff. This function finds the date value for a field that isn't specifically a Date data type so that Spiff can use the date value in calculations and other functions related to dates.
- **[date\_between?](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_date_between.htm&release=264.0.0&type=5)**  
    Checks whether a date falls within an upper and lower date range in Salesforce Spiff. When used in a calculated field, this function returns `true` or `false`.
- **[datevalue](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_datevalue.htm&release=264.0.0&type=5)**  
    Converts a string or object that represents a date or time value into an integer in Salesforce Spiff. The integer represents the elapsed days since December 30, 1899. This function helps you compare date values more easily.
- **[day](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_day.htm&release=264.0.0&type=5)**  
    Returns the number of the calendar day for a specified date or time in Salesforce Spiff.
- **[days\_ago](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_days_ago.htm&release=264.0.0&type=5)**  
    Returns the date that's a specified number of days before another date in Salesforce Spiff.
- **[days\_to](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_days_to.htm&release=264.0.0&type=5)**  
    Returns the number of days between two dates or times in Salesforce Spiff.
- **[error](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_error.htm&release=264.0.0&type=5)**  
    Returns a custom message for a statement calculation error in Salesforce Spiff. This function stops statement calculations and helps you alert admins that information is missing or preventing the calculation from executing.
- **[exp](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_exp.htm&release=264.0.0&type=5)**  
    Returns the value of the mathematical constant `e`, the base of the natural logarithm, raised to the power of a specified number for use in Salesforce Spiff. The value of `e` is approximately 2.72.
- **[filter](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_filter.htm&release=264.0.0&type=5)**  
    Further filters records in a Salesforce Spiff data filter, list, or relationship and returns a list of records that match a specified condition. This function helps refine an existing data filter.
- **[first](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_first.htm&release=264.0.0&type=5)**  
    Returns the first item in a sorted list in Salesforce Spiff.
- **[if](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_if.htm&release=264.0.0&type=5)**  
    Tests for a condition in Salesforce Spiff and returns different values depending on the outcome.
- **[iferror](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_iferror.htm&release=264.0.0&type=5)**  
    Checks whether an expression results in an error or null value in Salesforce Spiff and either returns the result of the expression or returns a default value for error handling. This function provides an alternative nested `if()` statements, but this function can also disguise real errors and result in inaccurate calculations if not used carefully.
- **[ifnull](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_ifnull.htm&release=264.0.0&type=5)**  
    Replaces a null value in a field with a specified value in Salesforce Spiff.
- **[ifs](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_ifs.htm&release=264.0.0&type=5)**  
    Returns the first true result from a series of logical tests in Salesforce Spiff. This function is similar to multiple if() functions. You can include multiple conditions and return different values based on the result of each condition.
- **[last](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_last.htm&release=264.0.0&type=5)**  
    Returns the last item in a sorted list in Salesforce Spiff.
- **[ln](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_ln.htm&release=264.0.0&type=5)**  
    Returns the natural logarithm of a specified number in Salesforce Spiff. The natural logarithm is based on the mathematical constant `e`, the value of which is approximately 2.72.
- **[mamount](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_mamount.htm&release=264.0.0&type=5)**  
    Returns the commission total for a deal in Salesforce Spiff, based on a range table and the rep's current attainment. To return a commission rate instead, use the `mpercent()` function.
- **[managers](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_managers.htm&release=264.0.0&type=5)**  
    Returns a list of user objects for managers of one or more teams in Salesforce Spiff, based on a specific date range and levels of team hierarchy. To return team members and managers, use the `members()` function.
- **[members](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_members.htm&release=264.0.0&type=5)**  
    Returns a list of user objects for users who belong to one or more teams in Salesforce Spiff, based on a specific date range and levels of team hierarchy. Optionally return both managers and team members or team members only. To return managers only, use the `managers()` function.
- **[month](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_month.htm&release=264.0.0&type=5)**  
    Returns the number of the calendar month for a specified date or time in Salesforce Spiff.
- **[monthname](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_monthname.htm&release=264.0.0&type=5)**  
    Returns the full or abbreviated name of the calendar month for a specified date or time in Salesforce Spiff.
- **[months\_ago](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_months_ago.htm&release=264.0.0&type=5)**  
    Returns the date that's a specified number of months before another date in Salesforce Spiff.
- **[months\_to](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_months_to.htm&release=264.0.0&type=5)**  
    Returns the number of months between two dates or times in Salesforce Spiff. If the return value is a negative number, the second date occurred before the first date.
- **[mpercent](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_mpercent.htm&release=264.0.0&type=5)**  
    Returns the commission rate for a deal in Salesforce Spiff, based on a range table and the rep's current attainment. To return a commission total amount instead, use the `mamount()` function.
- **[name](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_name.htm&release=264.0.0&type=5)**  
    Returns the name of a logic reference such as a calculation, data filter, or API name in Salesforce Spiff. The returned name can be different from the item's corresponding display name.
- **[networkdays](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_networkdays.htm&release=264.0.0&type=5)**  
    Returns the number of work days between an upper and lower date or time in Salesforce Spiff, excluding weekends and holidays.
- **[numbervalue](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_numbervalue.htm&release=264.0.0&type=5)**  
    Converts a text string or currency value into an integer or decimal in Salesforce Spiff.
- **[periods\_ago](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_periods_ago.htm&release=264.0.0&type=5)**  
    Returns the statement period start date that's a specified number of statement periods before another date in Salesforce Spiff.
- **[quota](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_quota.htm&release=264.0.0&type=5)**  
    Returns a quota value from a quota table in Salesforce Spiff. To sum values across multiple reps for a specific quota, use the `quotas()` function instead.
- **[quotas](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_quotas.htm&release=264.0.0&type=5)**  
    Returns a list of quota values from a quota table in Salesforce Spiff. The quota values are for a specific user in a specific time period.
- **[range\_lookup](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_range_lookup.htm&release=264.0.0&type=5)**  
    Returns a value from within an upper and lower range of values in Salesforce Spiff, based on a range table. This function returns the specified column expression for that value.
- **[rank](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_rank.htm&release=264.0.0&type=5)**  
    Compares a list of filtered numbers that represent rep metrics in Salesforce Spiff, such as monthly attainment, and returns a ranking relative to the rest of the list. This function doesn't break ties and awards the same ranking to all numbers that tie.
- **[single](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_single.htm&release=264.0.0&type=5)**  
    Returns the first and only record of a list in Salesforce Spiff. This function validates that only one record is returned and converts the list of records into an individual record.
- **[sort](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_sort.htm&release=264.0.0&type=5)**  
    Organizes records in a Salesforce Spiff data filter by a date, string value, or number value and returns a list of sorted records.
- **[sum](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_sum.htm&release=264.0.0&type=5)**  
    Calculates a total value from a list of numbers in Salesforce Spiff. This function works well with records in a data filter.
- **[sumif](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_sumif.htm&release=264.0.0&type=5)**  
    Calculates a total value from a list of numbers in Salesforce Spiff, but only for records that satisfy a specified condition.
- **[switch](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_switch.htm&release=264.0.0&type=5)**  
    Compares an input value against a list and returns a corresponding value or error message in Salesforce Spiff. This function is similar to the `vlookup()` function except the lookup tables are specified within the function rather than in a lookup table.
- **[team](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_team.htm&release=264.0.0&type=5)**  
    Returns a Team object in Salesforce Spiff and includes all fields such as the team name, leads, and effective dates. Use this function with other functions that require a reference to a Team object.
- **[tier\_payout](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_tier_payout.htm&release=264.0.0&type=5)**  
    Returns a payout amount from within an upper and lower range of values in Salesforce Spiff, based on a range table. This function returns the specified column expression for that value.
- **[transform\_list](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_transform_list.htm&release=264.0.0&type=5)**  
    Applies an expression to each record in a data filter in Salesforce Spiff and returns a new list with the results. For example, identify a specific field from a list of records and return a list of the values for only that field from those records.
- **[users\_in\_team](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_users_in_team.htm&release=264.0.0&type=5)**  
    Returns a list of user IDs from a team in Salesforce Spiff. Combine other functions to count the number of reps on a team or sum team member quotas. For a rollup of team members, use a Guided Rollup instead.
- **[vlookup](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_vlookup.htm&release=264.0.0&type=5)**  
    References a value from a lookup table in Salesforce Spiff and returns the specified column expression for that value.