---
schema_version: "1"
id: 8d2bf884d29650ab7fb7046325226bfefda852d120af3238b634fd6c0f8d704c
title: if
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref_if.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_if.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: a6e91b9e3ab35bc6cc2f6deef46cd863dce7886cc751a29c1254488aa9d6e17b
description: Tests for a condition in Salesforce Spiff and returns different values depending on the outcome.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# if

Tests for a condition in Salesforce Spiff and returns different values depending on the outcome.

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

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