You are here:
if
Tests for a condition in Salesforce Spiff and returns different values depending on the outcome.
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
if(condition, if_true_value, if_false_value)Arguments
| Argument | Required? | Description |
|---|---|---|
| condition | Required | Any expression or formula that results in either true or false. To compare values, specify comparison operators or logical functions such as AND or OR. |
| if_true_value | Required | The value to return if the condition is true. |
| if_false_value | Required | The value to return if the condition is false. |
Example
The formula TotalWidgets counts the number of widgets in the Qty field for a data filter called ClosedInPeriodWidgets. Test whether TotalWidgets is greater than or equal to 10. If true, return 300. If false, return 0.
=if(TotalWidgets >= 10, 300, 0)You can nest an if() function inside another if() function. For example, test whether a PerformanceGoal field contains the string PerformanceGoal1 and return the formula Goal_1_Weight. If not, test whether the field contains the string PerformanceGoal2 and return the formula Goal_2_Weight. If not, check whether the field contains the string PerformanceGoal3 and return the formula Goal_3_Weight. Otherwise, return 0.
=if(PerformanceGoal = "PerformanceGoal1", Goal_1_Weight,
if(PerformanceGoal = "PerformanceGoal2", Goal_2_Weight,
if(PerformanceGoal = "PerformanceGoal3", Goal_3_Weight, 0)))As soon as a nested if() function is true, the function doesn't evaluate any of the remaining conditions.

