CEILING() Function in Salesforce

In this Salesforce tutorial, we will learn the CEILING() function in Salesforce and how we can use it to calculate the round-up of a number. In addition, we will also focus on its syntax and some practical examples.

While employed in a Sales Organization that uses Salesforce as a customer relationship management tool to record product prices. I got a task to calculate the round of the original price of the product to the nearest integer.

Here, I found a CEILING() function as a solution that helped me to calculate the rounded price of the original price of the product. Now, let us discuss in detail, how to use the CEILING() function to calculate the price in Salesforce Lightning as well as Salesforce Classic.

What is the CEILING() function in Salesforce

The CEILING() function in Salesforce is one of the many mathematical functions available in Salesforce that may be used to carry out mathematical calculations.

This CEILING() function is used to round a numerical value up to the nearest integer away from zero if negative. And the resultant rounded value is larger than or equal to the original value always.

The Salesforce CEILING() function only supports numeric data types like Decimals and Integers. And if we try to use text, dates, or other non-numeric data types, it will produce an error.

Syntax and Usage of Salesforce CEILING() function

Below is the syntax for the CEILING() function in Salesforce:

CEILING(number/field/formula)

The value of the number/field/formula parameter is the value for which we are trying to round up the value. The value of the parameter can be a field, a constant number, or a complex formula.

Let’s look at an example to better understand the CEILING() function concept and syntax.

As I have discussed above that I got a task to find the round of the original price of the product to the nearest integer. For this, I will use the CEILING() function of Salesforce.

Let’s see its formula:

CEILING(Original Price)

Here, we simply pass the original price of the product to the CEILING() function.

With this, we have learned CEILING() function syntax, logic, and demonstration. Now, let’s move ahead and learn to determine the nearest rounded value using the Salesforce Lightning Component.

Read MCEILING() Function in Salesforce

How to use CEILING() function in Salesforce Lightning

Here, are the steps to calculate the nearest integer by using the CEILING() function in Salesforce Lightning:

See also  CONTAINS() Function in Salesforce

Step 1: Log in to Salesforce Lightning mode first, then click the “Gear Icon” in the top right corner of the page. Click “Setup” from the dropdown menu to continue.

CEILING Function in Salesforce

Step 2: Select “Object Manager” from the menu’s left side.

CEILING Function in Salesforce Example

Step 3: Use the search bar to look for the object you want to use with the CEILING() function. Since I want to calculate the order production in this example, I look for the “Order” object.

Step 4: Now, click the “Order” object, and the order Page will be displayed.

CEILING Function in Salesforce Lightning

Step 5: Select “Field and Relationship” from the menu on the left-hand side of the page.

Step 6: Press the “New” button to add a new formula field where the CEILING() function can be used.

CEILING Function in Salesforce Lightning Example

Step 7: It will forward to the “Choose the field type” page; select the “Formula” data type by selecting the radio button next to it.

Step 8: Click the “Next” button to proceed.

How to use CEILING function in Salesforce

Step 9: After entering the “Field Label” for the formula, the unique “Field Name” will be filled up automatically. I enter “Order Production” into the field label in this instance.

Step 10: Select the “Data Type” for the field where the nearest round of value will be calculated. A numeric data type, such as “Number”, “Currency”, etc., must be indicated for the data type.

Here, I choose “Number” as the formula return type so click the radio button to the right of it.

Step 11: At this step, click the “Next” button to proceed to the next step.

How to use CEILING function in Salesforce Example

Step 12: Enter the formula to compute the rounds of a number up to the nearest integer, using the CEILING function in the advanced formula editor.

I want to calculate the rounds of a number “Order Production” in this case, using the CEILING() function. The formula is as follows:

CEILING(Demand_Order__c / Unit_Size__c)
  • The “Order Production” s determined by the formula using the “Demand Order” and the number of “Unit Size”.
  • First, we divide the “Demand Order” field by the “Unit Size” field value and then calculate the nearest integer value by passing the resultant value to the CEILING() function.

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

Step 14: Alternatively, we may define the “Description” and “Help text” as well as “Handle the empty field” if we like.

Step 15: To continue, click on the “Next” button.

How to use CEILING function in Salesforce Lightning

Step 16: Select the appropriate “Level Security” option. I have selected “Visible” in this case because I want it to be visible to everyone. Next, select the “Next” button from the top side.

How to use CEILING function in Salesforce Lightning Example

Step 17: Following that, choose “Page Layout”.

See also  LEFT Function in Salesforce

Step 18: Click the “Save” button, in order to save the formula field.

How to use CEILING function using Salesforce Lightning

Once we’ve set up the formula field, we may use it. Let’s examine an illustration:

  • Create a new order with the fields “Demand Order” and “Unit Size” by opening the Orders Tab.
  • Click on the Details section after that, and the “Order Production” field will display the CEILING() function result.
How to use CEILING function using Salesforce Lightning Example

As a result, we now know how to calculate the nearest round of integer value in Salesforce Lightning. Now, we’ll look at how to calculate the nearest round of integer value in Salesforce Classic.

Check out, FLOOR() Function in Salesforce

How to use the CEILING function in Salesforce Classic

Here, are the steps to use the CEILING function in Salesforce Classic to calculate the roundup value to the nearest integer.

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

CEILING Function in Salesforce Classic

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

CEILING Function in Salesforce Classic Example

Step 3: Now, scroll down to the “Build” section. Then under “Customize“, select the object for whom field we want to use the CEILING() function. In this case, I select the “Campaign” object as I want to calculate the budget.

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

How to use CEILING function in Salesforce Classic

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

How to use CEILING function in Salesforce Classic Example

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.

Use CEILING function in Salesforce Classic

Step 8: The unique “Field Name” will be filled out automatically when you enter the “Field Label” for the formula. I entered “Campaign Budget” as a field label value.

Step 9: Select the “Data Type” for a field that we want to calculate the nearest round of the integer value. Make sure the data type must be of a numeric type such as “Number“, “Currency“, etc.

In this case, I check the radio button in front of the “Currency” to set it as the formula return type. And I also set the decimal point to 2.

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

Use CEILING function in Salesforce Classic Example

Step 11: Move to the advance formula editor, and enter the formula that uses the CEILING function to calculate the nearest integer value of the rounded number.

See also  Salesforce FormatDuration Function

In this case, I want to calculate the round-off value of the campaign budget for the campaign event using the CEILING function. And here is the formula.

CEILING(Total_Budget__c * Allocation_Percentage__c)
  • This formula calculates the campaign budget using the CEILING() function.
  • For this, we first multiply the value of the field “Total Budget” by the value of the field “Allocation Percentage”.

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 ahead toward the next step.

How to use CEILING function using Salesforce Classic

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.

Calculate nearest integer value in Salesforce

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.

Calculate nearest integer value in Salesforce Example

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 field “Total Budget” and “Allocation Percentage”.
  • On Save, it will redirect us to the Detail page, and here the “Campaign Budget” field appears which shows us the result of the CEILING() function.
Calculate nearest integer value in Salesforce Classic

As a result, we now know how to calculate the round-up value to the nearest integer in Salesforce Classic.

Conclusion

The Salesforce function CEILING() is a great function to work with numerical data in Salesforce. In addition, we have learned practical examples such as calculating Order Quantity, Campaign Budget, Nearest rounded integer, etc.

I hope you understood the concept of the CEILING function in Salesforce with it’s syntax and procedure of calculating the nearest rounded integer value in Salesforce Lightning and Salesforce Classic.

You may also like the following Salesforce tutorials: