# FLOOR() Function in Salesforce | Calculate round off nearest integer in Salesforce

In this Salesforce Tutorial, we will learn the FLOOR() function and how we can use it for calculating the nearest round-off integer of numerical data. Moreover, we will focus on the syntax of the FLOOR() function and some practical scenarios for implementation.

While working as an interior designer in a company in the United States of America. I got a task to adjust the product on the shelves of the bookstore. To give a bookstore a fabulous look I need to calculate the number of shelves required.

So as a solution, I find out that the FLOOR() function that determines the number of shelves based on the maximum capacity of one shelve. Let’s move and learn the procedure of how to use the FLOOR() function in Salesforce Lightning and the Salesforce Classic component to determine the nearest round-off integer.

## What is FLOOR function in Salesforce

There are various mathematical functions present in Salesforce for processing mathematical calculations and the FLOOR() function is one of them. This FLOOR() function is used to calculate the nearest round-off integer value.

Moreover, the FLOOR() function only supports numeric data types like Integer and Decimals. If you still try to use text, dates, or other non-numeric data types, it will give an error.

### Syntax and Usage of FLOOR function in Salesforce

Below is the syntax of the FLOOR() function in Salesforce:

``FLOOR(number/field/formula)``

The value for which we are trying to find out the nearest round-off integer is the value of the number, field, or formula parameter. In addition, the parameter value can be a field, a fixed number, or an advanced formula.

Now, let’s look at the example to better understand the FLOOR() function.

As I mentioned above, I was given the assignment to determine the “Product Allocation” and to do this I use the Salesforce FLOOR() function. Here, is the complete formula that calculates and applied in Salesforce:

``FLOOR(Total_Product__c / Max_Product__c)``

With this, we have learned FLOOR() function syntax, logic, and demonstration. Now, letâ€™s move ahead and learn to determine the nearest round-off value using the Salesforce Lightning Component.

## Calculate nearset round off value using FLOOR function in Salesforce Lightning

Here, are the steps to calculate the nearest round-off value using the FLOOR function in Salesforce Lightning:

Step 1: First, log in to Salesforce Lightning mode and navigate to the right corner of the page, then click on the“Gear Icon”. Now, from the dropdown menu click on “Setup”.

Step 2: From the left side of the menu, click on “Object Manager”.

Step 3: Search for the object in the search bar where we wish to utilize the FLOOR() function. In this case, I search for the “Campaign” object as I want to track the reach of advertising campaigns.

Step 4: Now, click on the “Campaign” object and it will redirect us to the campaign page.

Step 5: From the left side of the page click on the “Field & Relationship” option.

Step 6: Click on the “New” button to create a new field where we can use the FLOOR() function.

Step 7: It will redirect to the “Choose the field type” page, now check the radio button in front of the “Formula” data type.

Step 8: To proceed to the next step, click on the “Next” button.

Step 9: Enter the “Field Label” for the formula and the unique “Field Name” will be automatically populated. In this case, I entered the field label named “Advertisement Reach”.

Step 10: Choose the “Data Type” for the field for which we want to calculate the nearest round off of integer value.

Make sure the data type must be of a numeric type such as Number. So, I check the radio button in front of the “Number” to set it as the formula return type and here I set the decimal point to 2.

Step 11: Move to the next step by clicking on the “Next” button.

Step 12: Move to the advanced formula editor, and enter the formula that uses the FLOOR() function. In this case, I want to calculate the reach of advertising campaigns using the FLOOR() function. Here, is the formula:

``FLOOR(Total_Reach__c / Number_of_Ads__c)``

Here, we first divide the field value of “Number of Ads” by the field value of “Total Reach”. Next, we pass the resultant value to the FLOOR() function and determine the advertisement reach of the campaign.

Step 13: Click on the “Check Syntax” button to validate the formula and ensure that there are no errors.

Step 14: Optionally, we can “Handle the empty field” as well as we can define the “Description” and “Help text” if we want.

Step 15: Click on the “Next” button to move to the formula field-level security step.

Step 16: Select the relevant “Level Security” field. I have selected “Visible” in this case because I want it to be visible to everyone. Then, click on the “Next” button.

Step 17: Now, select the appropriate “Page Layout” where we want to be visible.

Step 18: Click on the “Save” button to save the formula field.

We can use the formula field once weâ€™ve created it. Letâ€™s look at an example:

• Open the Campaigns Tab and create a new campaign with the fields “Total Reach” and “Number of Ads”.
• After that, click on the Details section, and here the “Advertisement Reach” field appears which shows you the result of the FLOOR() function.

As a result, we now knowÂ how to calculate the nearest round-off value using the FLOOR function in Salesforce Lightning.Â Now, weâ€™ll look at how to calculate the nearest round-off value using the FLOOR function in Salesforce Classic.

## Calculate nearest round off value using FLOOR function in Salesforce Classic

Here, are the steps to calculate the nearest round-off value using the FLOOR function in Salesforce Classic:

Step 1: From the Salesforce Lightning to open your Salesforce Classic edition. Click on Avtar and then click Switch to Salesforce Classic.

Step 2: After that, click on the Setup option.

Step 3: Now, scroll down to the Build section. Then under Customize, select the object for whom field we want to use the FLOOR() function. In this case, I select the “Leads” object as I want to track lead conversion to contacts rate.

Step 4: Click on the “Leads” dropdown and select the “Fields” option to get the option of the new field.

Step 5: Now scroll down to the “Lead Custom Fields & Relationships” and click on the “New” button to create a new formula field.

Step 6: It will redirect to the “Choose the field type” page, now check the radio button in front of the “Formula” data type.

Step 7: To proceed to the next step, click on the “Next” button.

Step 8: The unique “Field Name” will be filled out automatically when you enter the “Field Label” for the formula. I entered “Lead Conversion Rate” into the field labeled in this instance.

Step 9: Select the “Data Type” for a field that we want to calculate the nearest round-off value. Make sure the data type must be of a numeric type such as “Number”. So, I check the radio button in front of the “Number” to set it as the formula return type. I also set the decimal place to 0.

Step 10: Now click the “Next” button to go to the next step.

Step 11: Move to the advanced formula editor, and enter the formula that uses the FLOOR() function to calculate the nearest round-off integer value. In this case, I want to calculate the lead conversion rate using the FLOOR() function. Here, is the formula:

``FLOOR(Conversion__c / Total_Leads__c * 100)``

Step 12: To check the formula and make sure there are no mistakes, click the “Check Syntax” option.

Step 13: Optionally, we can define the “Description” and “Help text” as well as “Handle the empty field” if we prefer.

Step 14: Click on the “Next” button to move to the next step.

Step 15: Select the relevant “Level Security” field. I have selected “Visible” in this case because I want it to be visible to everyone. Following that, select “Next” to move ahead.

Step 16: Now, select the appropriate “Page Layout” where we want this field to be visible.

Step 17: Lastly, click on the “Save” button to save the formula field.

We can use the formula field once weâ€™ve created it. Letâ€™s look at an example:

• Open the Lead Tab and create a new lead with the fields “Conversion”, and “Total Lead“.
• On save, it will redirect us to the Detail Page, and here the “Lead Conversion Rate” field appears which shows us the result of the FLOOR() function.

As a result, we now know how to calculate the nearest round-off value using the FLOOR function in Salesforce Classic.

## Conclusion

With this, we have concluded that the Salesforce function FLOOR() is an excellent tool for handling numerical data. Additionally, we have learned how to calculate the nearest round-up-off integer value.

Furthermore, we have also understood the concept of the FLOOR() function its syntax, and the procedure for calculating the round-up off the nearest value in Salesforce Lightning and Salesforce Classic.

You may also like the following Salesforce function tutorials: