Recently, I was hired by a New York-based company that uses Salesforce CRM to manage its operations. I was given a job at work that required me to determine the overall amount of funds raised for the campaign.
As a solution, I discovered that Salesforce gives us the function named “MOD”, which helps in determining the remainder when a number is divided by a given divisor.
In this tutorial, we will learn about the MOD() function in Salesforce. In addition, we’ll learn the syntax and real-world Salesforce use cases for this function.
What is the MOD Function in Salesforce
The MOD() function in Salesforce is a mathematical function used to perform calculations. In basic terms, the MOD() function returns the remainder when a number is divided by a specified divisor.
Additionally, only numerical data types—Integers, Decimals, and Currency — are supported by the MOD() function. However, if you attempt to utilise a text, date, or other non-numeric data type, an error will result.
The Salesforce MOD() function syntax is as follows:
MOD(dividend, divisor)Here, the divisor is the number by which the dividend is divided, and the dividend is the number that is being divided. The value of the parameter divided by the divisor can be a field, a constant number, or a complex formula.
To better understand how the MOD function works, let’s look at an example.
As I mentioned above, I need to figure out how much money the campaign raised overall. I will therefore utilise the Salesforce MOD() method for this. The formula is as follows:
MOD(Total_Contribution__c, Total_Amount__c)With this, we learned the syntax of the MOD() function as well as an example. We’ll now look at how to use the MOD() function in Salesforce.
MOD() Function in Salesforce: Calculate Remainder in Salesforce
The steps to use the MOD() function in Salesforce are as follows:
- Log in to Salesforce org, then click the “Gear Icon” in the top right corner of the page. To proceed, click “Setup“ from the dropdown menu.

- The “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.

- The object manager page opens when you click it. Now, click the “Campaign” object to move to the campaign object page.

- On the campaign object page, select “Field & Relationship“ from the menu.
- The field and relationships page is opened after selecting the field and relationship option. Click the “New” button at the top of the field and relationship page.

- The data type page opens when you click the new button. The page contains a wide variety of data types. In this case, I chose the “Formula” data type field, as I want to use the MOD function in the advanced formula.
- Click the “Next” button to move on to the following step.

- Enter the information now by filling out the “Field Label” and the “Field Name”, which is automatically filled in when you click on the field. I typed “Votes Needed” into the field label in this instance.
- Choose the “Output Data Type“ for the field in which we want to store the result. In this case, I check the radio button next to the “Number” data type to return the formula result as a number, and I also set the “Decimal Place” to 2.
- Move to the next step by clicking the “Next” button.

- Go to the advanced formula editor and type the MOD() function formula there. In this instance, I want to use the MOD function to determine how many votes we needed to reach the desired level. The formula is as follows:
MOD(Total_Voter__c, Candidate_Support__c)- This formula is used to determine the remainder after dividing the total number of voters “Total_Voter__c” by the candidate’s support “Candidate_Support__c”, to determine how many more votes we need to win a majority.
- To validate the formula and make sure there are no mistakes, click the “Check Syntax” option.
- Optionally, we may define the “Description,” “Help text,” and “Handle the empty field” if we like.
- Press the “Next” button to go to the security stage for the formula field.

- In this step, establish “Field-Level Security“.Now choose the profiles to which we wish to grant field-level security edit access to this field. If field-level security is not added, the field will be hidden from all profiles.
- Because I want it to be visible to all profiles, I have chosen “Visible” in this instance. After that, click the “Next” button located at the top.

- Add the custom field to the “Page Layout“ after setting up the field-level security. Pick the page layout that has this field in it. If we do not select a layout, the field will not appear on any pages.
- To save the formula field, click the “Save” button.

- We can use the formula field once we’ve created it. Let’s look at an example:
- Open the Campaign Tab and create a new campaign with the fields Total Voters and Candidate Support.
- The Estimated Votes field, which displays the output of the MOD() function, then appears when you click on the Details Section.

As a result, we now understand how to use Salesforce Lightning MOD() Function.
Conclusion
As a result, we can conclude that the Salesforce MOD() Function is an excellent and effective method to obtain the remainder after a number has been divided by a defined divisor. Additionally, we focused on the MOD() Function syntax and several real-world business scenarios.
You may like to read:
- MFLOOR() Function in Salesforce
- MCEILING() Function in Salesforce
- Round() Function in Salesforce
- ATAN() Function in Salesforce
- Salesforce DAY Function
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.