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.
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.34.
Build your formula:
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.
To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list.
Optionally, click the Advanced Formula tab to use functions and view additional operators and merge fields. Functions are prebuilt formulas that you can customize with your input parameters.
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.
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:
/*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 */
You can also use comments to comment out sections of your formula when debugging and checking the syntax to locate errors in the formula.
Nesting comments causes a syntax error. For example, you cannot save a formula that has the following:
/* /* comment */ */
Commenting out a whole formula causes a syntax error.
Comments count against the character and byte size limits in formulas.
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.
To check your formula for errors, click Check Syntax.
Optionally, enter a description of the formula in the Description box.
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.
Set the field-level security to determine whether the field should be visible for specific profiles, and click Next.
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.
Click Save to finish or Save & New to create more custom fields.
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.