MCEILING() Function in Salesforce | Syntax, Examples, & Use Cases

Recently, I worked as a system administrator at a company that uses Salesforce to run its business efficiently. While working, I was assigned the task of calculating the number of leads required to meet the target.

As a solution, I discovered that Salesforce gives us the “MCEILING” function that helps in calculating the round-off value nearest to the integer.

In this tutorial, we will learn the MCEILING() function in Salesforce. In addition, we will learn the syntax and practical use cases for this function in Salesforce.

MCEILING() Function in Salesforce

The MCEILING() function in Salesforce is a mathematical function used to round numbers up.

Basically, the MCEILING() function rounds a numerical value up to the nearest integer; if the value is negative, it rounds down to the nearest integer.

In addition, the MCEILING() function only supports numerical data types such as Integers, Decimals, and Currency. But if you try to use the text, date, or other non-numeric data type, it will produce an error.

The syntax of the Salesforce MCEILING() function is as given below:

MCEILING(number/field/formula)

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

Now, let’s see an example to understand the MCEILING() function completely:

As discussed above, I need to calculate the number of leads required to meet the target. For this, I will use the MCEILING() function in Salesforce. Here is the formula:

MCEILING(No_Of_Leads__c)

With this, we have learned the MCEILING() function, its syntax, and an example. Now, we will look at the differences between the MCEILING and CEILING functions in Salesforce.

MCEILING() Function vs CEILING() Function in Salesforce

The major difference between the Salesforce MCEILING() function and the CEILING() function is as follows:

MCEILING() Function: The MCEILING function rounds a number up to the nearest integer value. If the number is negative, it rounds towards zero.

CEILING() Function: The CEILING function rounds a number up to the nearest integer value. If the number is negative, it rounds the number away from zero.

Use of MCEILING() Function in Salesforce

Here are the steps to use the CEILING() Function in Salesforce.

  1. Log in to Salesforce mode, then click the “Gear Icon” in the top right corner of the page. Click Setup from the dropdown menu to continue.
MCEILING Function in Salesforce
  1. After clicking on the Setup option, the setup page opens. Click the “Object Manager” in the Navigation Bar near the Home tab.
MCEILING Function in Salesforce Example
  1. After clicking on it, the Object Manager page opens. Here, we can see many objects. Search for the object in the search bar where we wish to utilise the MCEILING() function.
    • In this case, I search for the “Order” object to count the total number of products required to fulfil an order.
    • Now, click the “Order” object; it will redirect us to the order object page.
MCEILING Function in Salesforce Lightning
  1. On this order object page, there is a details section on the left side that includes the “Field & Relationship” option. Click on the Field & Relationship option.
    • After clicking on the field and relationship option, the field and relationships page opens.
    • For using the MCEILING function, select the field type by clicking on the “New” button that is located at the top of the field and relationship page.
    MCEILING Function in Salesforce Lightning Example
    1. After clicking on the new button, the data type page opens. There are many data types on the page. Here, we are selecting the Formula data type field on the page. The formula field allows users to use the MCEILING() function.
      • To proceed to the next step, click on the “Next” button.
    Salesforce MCEILING Function
    1. After clicking on the following button, the Choose Output Type page opens. Now enter the details: first fill the “Field Label“, then the “Field Name“, which automatically fills in when you click the field. In this case, I entered the field label named “Product Needed”.
      • Choose the “Output Data Type for the field for which we want to calculate the product quantity.
      • Here, I select the data type as “Number” to get the formula return type as a number, so I check the radio button in front of it, and I also set the “Decimal Place” to 3.
      • Move to the next step by clicking on the “Next” button.
    Salesforce Example MCEILING Function
    1. Move to the advanced formula editor, and enter the formula that uses the MCEILING() function. In this case, I want to calculate the required quantity of the product using the appropriate function. Here is the formula:
    MCEILING( Order_Quantity__c / Items__c) * Items__c
    • Here, we first divide the order quantity field “Order_Quantity__c” by the item field “Items__c” and then pass the result to the MCEILING() function to round it to the nearest integer, rounding towards zero if negative.
    • Next, multiply the resulting value by the “Items__c” field.
    • Click on the “Check Syntax” button to validate the formula and ensure that there are no errors.
    • Optionally, we can “Handle the empty field,” and we can also define the “Description” and “Help text” if we want.
    • Click on the “Next” button to move to the formula field-level security step.
    How to use MCEILING Function in Salesforce Lightning Example
    1. Now the “Field-Level Security“. Now select the profiles to which we want to grant edit access to this field via field-level security. The field will be hidden from all profiles unless we add field-level security.
      • I have selected “Visible” because I want it to be visible to all profiles. Then click the “Next” button at the top.
    How to use MCEILING Function in Salesforce Example
    1. After establishing the field-level security, add the custom field to the “Page Layout”Select the page layout that should include this field. This field will be added as the last field of this page layout. The field will not appear on any pages unless we select a layout.
      • Click on the “Save” button to save the formula field.
    How to use MCEILING Function in Salesforce
    1. We can use the formula field once it’s created. Let’s look at an example:
      • Open the Orders Tab and create a new order with the Item and Order Quantity fields.
      • After that, click on the Details section, and here the Product Needed field appears, which shows you the result of the MCEILING() function.
    How to use MCEILING Function in Salesforce Lightning

    As a result, we now know how to use the MCEILING() Function in Salesforce.

    Conclusion

    In conclusion, we can say that the Salesforce MCEILING() Function is a wonderful and practical approach to round a number up to the nearest integer, or towards zero if it’s negative. We also focused on the MCEILING() Function syntax and several examples from the business world.

    Additionally, we went over the step-by-step instructions for using the MCEILING() Function in Salesforce.

    You may like to read:

    Agentforce in Salesforce

    DOWNLOAD FREE AGENTFORCE EBOOK

    Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

    Salesforce flows complete guide

    FREE SALESFORCE FLOW EBOOK

    Learn how to work with flows in Salesforce with 5 different real time examples.