A Formula Field in Salesforce is used as a read-only field that displays its value from a formula expression you define. It is updated when any of the source fields change.
In this Salesforce tutorial, we will learn about the formula field in Salesforce. In that, I will explain what a formula field is, what its purpose is, and how to create a formula field in Salesforce.
What is a Formula Field in Salesforce?
In Salesforce, the formula field is a feature that permits you to make custom fields whose values are calculated based on particular criteria or expressions. These formula fields are used in objects, reports, and workflows.
It is a read-only field, and the user can create a formula using functions, insert operators, and insert fields. The values of the formula field can be calculated from expressions we define.
If the value in the expression we can use is updated, the formula field value is automatically updated. Now, let’s move further and see how to create the formula field type in Salesforce Lightning and Salesforce Classic.
Read Salesforce Checkbox Formula
Create Formula Field in Salesforce
Creating a formula field in Salesforce requires special attributes like editions and user permissions, and it is not available in all orgs. You can also create a formula field in the Salesforce Lightning and Classic user interfaces.
For example, we want to calculate the monthly commission of the account that is based on the annual revenue.
If the lower annual revenue gets the 0.15% commission, then the higher annual revenues get the 0.05% commission. For creating this formula we are using the formula data type that is present under the field and relationship.
1. Click on the gear icon -> Select the setup option -> Click on the object manager tab –> Select the account object.

2. Select the field and relationship option that is present on the account page.

3. We want to create a new field. Click on the New button.

4. Choose the field type -> Select the Formula field type –> Click on the next button.

5. Now choose the output type. Fill the field label. Here, we are filling the field label as MonthlyRevenue, then fill the field name, and then clicking on the next option.
Choose the formula return type as a currency that can calculate a dollar or other currency amount and automatically format the field as a currency amount.

6. Click on the advanced formula tab -> select the IF function –> Click on the insert selected formula button.
Here, we set the formula as:
IF( AnnualRevenue <=100000, AnnualRevenue*0.15/12, AnnualRevenue*0.05/12).This formula shows that the annual revenue is above 100000. We will do the same calculation, but this time, the value of 0.05 represents a lower percentage. Then, we will divide by 12 again to represent the monthly amount.

7. After creating the formula, now establish the field-level security. Select the profiles we want to grant edit access to this field via field-level security.

8. After establishing the field-level security. Now, we can add the page layout. Select the page layouts that should include this field.

9. After clicking on the save button. The field and relationship page is open, and on this page, we can see that the monthly revenue formula currency field was created successfully.

This way, we understand how to create the formula type in Salesforce Lightning. Let’s Proceed and learn how to create the formula field type in Salesforce Classic.
How to Create Formula Field in Salesforce Classic
Here, we are creating the formula field type in Salesforce Classic
Consider a scenario where there is a user who wants to calculate how many days are left till the opportunity closes. For this, we want to create a simple formula that easily calculates the values.
After creating the field, the user can access the key information by simply adding the value to the opportunity page.
1. Log in to your Salesforce account –> Click on the Profile Picture –> Click on Switch to Salesforce Classic –> Go to the Setup –> Enter contract in Quick Find Box –> Click on the fields option.

2. Now scroll to the bottom of the page there is a field and relationship section present. Click on the new option and choose the field type. Here, we are selecting the formula field. Click on the next button.

3. Choose the output type. Fill the field label. Here, we are filling the field label as Days Remaining, then fill the field name, and then clicking on the next option.
Now, choose the formula return type. Here we are choosing the formula return type as a number that can calculate the numeric value.

4. Click on the advanced formula tab –> select the insert field –> select the contract and the end date of the contract.
Now click on the insert operator button –> Select the subtract operator.
Select the functions –> select the Today() function –> Click on the insert selected formula button.
Now, the formula is generated as
EndDate—Today().
5. Now, establish the field-level security after creating the formula. Select the profiles we want to grant edit access to this field via field-level security.

6. After establishing the field-level security, we can add the page layout. Select the page layouts that should include this field.

7. Now, we can add the page layout after establishing the field-level security. Select the page layouts that should include this field.
8. The field and relationship page is again open and under this page, we can see that the Days Remaining(Number) field is created successfully.

So, with this, we have learned how to create a formula field in Salesforce Classic.
Conclusion
I hope now you have an idea of the formula field in Salesforce and how to create a formula in Salesforce.
I have also explained the different formulas by using different scenarios in the Salesforce interface.
You may like to read:
- How to Create Lookup Relationship Field Type in Salesforce
- How to Add Validation Rule for Phone Field in Salesforce
- How to Create External Lookup Relationship Field Type in Salesforce
- How to Set Length For External Lookup Field in Salesforce

Vaishali is working as a Salesforce consultant and handling multiple Salesforce projects. She is highly skilled in Salesforce customization, integration, automation, and data analytics. She has successfully delivered numerous Salesforce projects on Contact Management System, Donation Tracking System for Nonprofits, E-commerce Platform Integration, etc. Read more | LinkedIn Profile