---
schema_version: "1"
id: 34ca23426ef16c8eb935ea3a95591576dbe8dbfed87babf857db1093a14e945d
title: CASE
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_case.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_case.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: cba4726ad3d74e2d757b9544013fc4d195b91e0c6f906fedbe580bd1dc257533
description: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any of the values, returns the else_result.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# CASE

Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any of the values, returns the `else_result`.

## Use

`CASE(expression,value1, result1, value2, result2,..., else_result)` and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else\_result with the value you want returned when the expression doesn't equal any values.

## Tips

- Be sure your value1, value2... expressions are the same data type.
- Be sure your result1, result2... expressions are the same data type.
- CASE functions can’t contain functions that return true or false. Instead, make true or false expressions return numbers such as:
    
    ```
    CASE(1, IF(ISPICKVAL​ (Term__c, "12"),​ 1, 0),
     12 * Monthly_Commit__c,​​
     IF(ISPICKVAL(Term__c, "24"), 1, 0),​​
     24 * Monthly_Commit__c, 0)
    ```
    
    In this formula, Term is a picklist field that is multiplied by the Monthly Commit whenever it contains the value 1 for true.
- The else\_result value is required.
- CASE functions return an error whenever any of the expressions return an error, regardless of which one must be returned. For example, `CASE(Field__c,"Partner", "P",​ "Customer", "C", LEFT(Field__c, -5))` returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical.
- If the field in your CASE function is blank, it returns your else\_result value. For example, this formula: `CASE(Days_Open__c, 3, "Reassign", 2,​ "Assign Task", "Maintain")` displays Maintain if the Days Open field is blank, 0, or any value other than 2 or 3.
- Use CASE functions to determine if a picklist value is equal to a particular value. For example the formula `CASE(Term__c, "12", 12 * Monthly_Commit__c, "24",​ 24 * Monthly_Commit__c, 0)` multiplies the Monthly Commit amount by 12 whenever the Term is 12 or multiplies the Monthly Commit amount by 24 whenever the Term is 24. Otherwise, the result is zero.

![Formula Field Example: Days Open for Cases](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: Days Open for Cases

Use this example of a custom formula field called Days Open to display different text depending on the number of days a case has been open:

```
CASE(Days_Open__c, 3, 
  "Reassign", 2, "Assign Task", "Maintain")
```

This text is displayed.

- “Reassign” for any case open three days.
- “Assign Task” for any case open two days.
- “Maintain” for all other cases.

![Formula Field Example: Last Activity Month](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: Last Activity Month

This formula field displays the month of the last activity or None if there are no activities.

```
CASE(MONTH(LastActivityDate),
1, "January",
2, "February",
3, "March", 
4, "April", 
5, "May", 
6, "June",
7, "July",
8, "August",
9, "September",
10, "October",
11, "November",
12, "December",
"None")
```

![Default Value Example: Discount 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)

Default Value Example: Discount Rate

Use this default value formula to insert a different discount rate on an opportunity based on the department of the person creating the opportunity.

```
CASE(User.Department,​​ "IT", 0.25, "Field", 0.15, 0)
```

In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department.

![Default Value Example: Product Language](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)

Default Value Example: Product Language

You want to associate a product with its language so that your users know the type of documentation or adapter to include. Use this default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field.

```
CASE($User.Country ,​​ "Japan", "Japanese", "US", "English","unknown")
```