---
schema_version: "1"
id: 8ffe5ebf0156e3263c65e10a75f67a77c4d82e1d7511a5b6fd908b51ca2c15c2
title: IF
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_if.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_if.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: edf1553fd00a4f419bf827699c4f049be129b83b24925ccd48d770d994716b1f
description: Determines if expressions are true or false. Returns a given value if true and another value if false.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# IF

Determines if expressions are true or false. Returns a given value if true and another value if false.

## Use

`IF(logical_test, value_if_true, value_if_false)` and replace logical\_test with the expression you want evaluated; replace value\_if\_true with the value you want returned if the expression is true; replace value\_if\_false with the value you want returned if the expression is false.

## Tips

- Make sure your value\_if\_true and value\_if\_false expressions are the same data type.
- When using an IF function with the $Profile.UserType variable to determine the type of Salesforce user license the logged in user has, use the following values:
    
    - Standard for Salesforce
    - PowerPartner for PRM User
    - CustomerSuccess for Customer Portal User
    - PowerCustomerSuccess for Customer Portal Manager
    
    For example, use the following formulas to determine if the logged in user has the license type in quotes:
    
    ```
    IF(ISPICKVAL($Profile.UserType ,"Standard"), 100, 0.1)
    ```
    
    ```
    IF(ISPICKVAL($Profile.UserType ,"PowerPartner"), 100, 0.1)
    ```
    
    ```
    IF(ISPICKVAL($Profile.UserType ,"CustomerSuccess"), 100, 0.1)
    ```
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_note.png)
    
    Note $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.

![Formula Field Example: Overdue Payments](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

Formula Field Example: Overdue Payments

`IF(AND(Payment_Due_Date__c < TODAY(),​​Payment_Status__c ="UNPAID") , "PAYMENT OVERDUE", ​null)`

This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, returns the text “PAYMENT OVERDUE” and if not, leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status.

![Formula Field Example: Insert Tax Rate](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

Formula Field Example: Insert Tax Rate

Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:

```
IF($User.City = "Napa", 0.0750, 
 IF($User.City = "Paso Robles", 0.0725, 
  IF($User.City = "Sutter Creek", 0.0725, 
   IF($User.City = "Los Olivos", 0.0750, 
    IF($User.City = "Livermore", 0.0875, null
    )
   )
  )
 )
)
```

![Custom Button Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

Custom Button Example

```
{! 
IF(Sample.BillingCountry = "US", 
"http://maps.google.com/maps?q=​"&Sample.BillingStreet&​
"+"&Sample.BillingCity&"+​"&Sample.BillingState&"+​"&Sample.BillingCountry, 
(IF(Sample.BillingCountry = "UK", 
"http://maps.google.co.uk/maps?q=​"&Sample.BillingStreet
&​"+"&Sample.BillingCity&​"+​"&Sample.BillingCountry, 
"http://maps.google.com"))) 
}
```

This example uses the IF function to determine if an address is in the United States or United Kingdom so that it can use the appropriate type of Google map to display the address.