---
schema_version: "1"
id: 77ba65ff1ef3865356d77c29f838de269737fc00fcdb63ebf569dbbecd354040
title: Build a Formula Field
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_formulas.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_formulas.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 6c57bb117a3a8d933472d6ac37bfa32c047ef44308deeb65edc170eb44246530
description: Your custom formula fields require special attributes.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Build a Formula Field

Your custom formula fields require special attributes.

### 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 and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>All</strong> Editions</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d179928e63">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d179928e63 ">To view formula field details:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d179928e63 ">View Setup and Configuration</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d179928e63 ">To create, change, or delete formula fields:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d179928e63 ">Customize Application</td>

          </tr>
        </tbody>
      </table>

![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 The [Getting Started with Formulas (Salesforce Classic)](https://salesforce.vidyard.com/watch/EC0MrR6ZMU4CiHyFaakGhg) help video includes a live demo of these steps.

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

Tip You can also complete this task using Setup with Agentforce. For more information, see [Setup with Agentforce](https://help.salesforce.com/s/articleView?id=xcloud.setup_agentforce_overview.htm&language=en_US) and [Formulas in Setup with Agentforce](https://help.salesforce.com/s/articleView?id=xcloud.setup_agentforce_formula.htm&language=en_US).

1. Begin building a formula field the same way you create a custom field. See [Create Custom Fields](https://help.salesforce.com/s/articleView?id=platform.adding_fields.htm&type=5&language=en_US).
2. Select the data type for the formula. Choose the appropriate data type for your formula based on the output of your calculation. See [Formula Data Types](https://help.salesforce.com/s/articleView?id=platform.choosing_a_formula_data_type.htm&release=264.0.0&type=5 "The data type of a formula determines the type of data you expect returned from your formula.").
3. Choose the number of decimal places for currency, number, or percent data types. This setting is ignored for currency fields in multicurrency organizations. Instead, the Decimal Places for your currency setting apply. Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
4. Click **Next**.
5. Build your formula. Formula fields can contain up to 3,900 characters, including spaces, return characters, and comments. If your formula requires more characters, create separate formula fields and reference them in another formula field. The maximum number of displayed characters after an evaluation of a formula expression is 1,300
    1. If you are building a formula in the **Advanced Formula** tab or for approvals or rules, such as workflow, validation, assignment, auto-response, or escalation, click **Insert Field**, choose a field, and click **Insert**. To create a basic formula that passes specific Salesforce data, select the **Simple Formula** tab, choose the field type in the Select Field Type drop-down list, and choose one of the fields listed in the Insert Field drop-down list. Build cross-object formulas to span to related objects and reference merge fields on those objects.
    2. To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list.
    3. Optionally, click the **Advanced Formula** tab to use functions and view other operators and merge fields. Functions are prebuilt formulas that you can customize with your input parameters.
    4. To insert a function, double-click its name in the list, or select it and click **Insert Selected Function**. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click **Help on this function** to view a description and examples of formulas using that function.
    5. Consider adding comments to your formula, especially if it is complicated. Comments must begin with a forward slash followed by an asterisk (`/*`), and conclude with an asterisk followed by a forward slash (`*/`).
        
        Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example:
        
        ```
        AND( 
        /*competitor field is required, check to see if field is empty */
        LEN(Competitor__c) = 0, 
        /* rule only enforced for ABCD record types */
        RecordType.Name = "ABCD Value",
        /* checking for any closed status, allows for additional closed picklist values in the future */
        CONTAINS(TEXT(StageName), "Closed") 
        )
        ```
6. To check your formula for errors, click **Check Syntax**.
7. Optionally, enter a description of the formula in the Description box.
8. If your formula references any number, currency, or percent fields, choose an option for handling blank fields. To give any blank fields a zero value, choose Treat blank fields as zeros. To leave these fields blank, choose Treat blank fields as blanks.
9. Click **Next**.
10. Set the field-level security to determine whether the field should be visible for specific profiles, and click **Next**.
11. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page.
12. Click **Save** to finish or **Save & New** to create more custom fields.

![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 Because formula fields are automatically calculated, they are read-only on record detail pages and do not update last modified date fields. Formula fields are not visible on edit pages.

In account formulas, all business account fields are available as merge fields. However, account fields exclusive to person accounts such as Birthdate and Email are not available.

- **[What Is a Cross-Object Formula?](https://help.salesforce.com/s/articleView?id=platform.customize_cross_object.htm&release=264.0.0&type=5)**  
    A Cross-object formula is a formula that spans two related objects and references merge fields on those objects. A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with lookup relationships.

#### See Also

- [Elements of a Formula](https://help.salesforce.com/s/articleView?id=platform.elements_of_a_formula.htm&release=264.0.0&type=5 "Learn the elements you can combine to build a formula: literal values, field references, functions, operators, and comments. Understand what each element does and see an example of how to enter it.")
- [Merge Fields for Formulas](https://help.salesforce.com/s/articleView?id=platform.fields_merge_fields_formulas.htm&release=264.0.0&type=5 "A merge field is a field you can put in an email template, mail merge template, custom link, or formula to incorporate values from a record.")
- [Tips for Building Formulas](https://help.salesforce.com/s/articleView?id=platform.tips_on_building_formulas.htm&release=264.0.0&type=5 "Extend your Salesforce data with powerful formula logic. Access a collection of tips for using specific data types in your formulas, including dates, numbers, text, picklists, and record types.")
- [Formula Operators and Functions by Context](https://help.salesforce.com/s/articleView?id=platform.customize_functions.htm&release=264.0.0&type=5 "Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula, such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.")