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

I recently started working for a US-based IT company that manages its client relationships using the robust Salesforce system. I was assigned to determine the contact’s minimum age.

As a solution, I discovered that Salesforce gives us the function named “MIN() Function”, which is used to calculate the minimum value of the field.

In this Salesforce Tutorial, we will learn the MIN() Function in Salesforce and how to calculate the minimum value from a list of numbers or fields.

In addition, we will learn the syntax and some of the practical industrial use cases of the MIN() Function.

What is the MIN() Function in Salesforce?

The MIN() Function is one of the math aggregate functions available in Salesforce that may be used to perform mathematical calculations. Using the Salesforce MIN() function, we can determine the smallest value in a list.

The MIN() function syntax is as follows:

MIN(number/field/formula)

The MIN() function may be applied to a fixed list of numbers, fields, or complex formulas as the parameter value.

Additionally, only numerical data types like Numbers, Decimals, and Currency are supported by the MIN() function. And it will give us an error if we try to utilise text, dates, or any other non-numeric data types.

Let’s now look at an illustration that clarifies the idea and syntax of the MIN() function.

Let’s say we want to know at least how many orders can be registered. I use Salesforce’s MIN() function for this, and the formula is as follows:

MIN(Minimum_Orders__c)

With the help of this, we learned the MIN() function syntax, explanation, and demonstration. See how to use Salesforce to determine the lowest number from a list of numbers in the next section.

MIN() Function in Salesforce: Calculate Minimum Value

Here are the steps to find out the minimum value of the field in Salesforce Lightning:

  1. Log in to Salesforce org, then click the “Gear Icon” in the top right corner of the page. Click Setup from the dropdown menu to continue.
MIN Function in Salesforce
  1. From the left side of the menu, click on “Object Manager”.
MIN Function in Salesforce Example
  1. Search for the object in the search bar where we wish to utilise the MIN() function. In this case, I search for the “Order” object to track the minimum shipping charge for the product.
    • Now, click the “Order” object; it will redirect us to the order page.
MIN Function in Salesforce Lightning
  1. From the left side of the page, click on the Field & Relationship option.
    • Click on the “New” button to create a new field where we can use the MIN() function.
MIN Function in Salesforce Lightning Example
  1. It will redirect to the “Choose the field type” page. Now, check the radio button in front of the “Formula” data type.
    • To proceed to the next step, click on the “Next” button.
Calculate minimum value in Salesforce
  1. 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 “Minimum Shipping Charges”.
    • Choose the Data Type for the field for which we want to calculate the minimum shipping charges of the order.
    • Here, I select the data type as “Currency” to get the formula’s return type as a price value, so I check the radio button next to it.
    • Move to the next step by clicking on the “Next” button.
Calculate minimum value in Salesforce Example
  1. Move to the advanced formula editor, and enter the formula that uses the MIN() function. In this case, I want to calculate the minimum shipping price of the order using the MIN() function. Here is the formula:
MIN(Shipping_Price__c, 100)
  • In this formula, we pass the order field “Shipping_Price__c” as the first value to the MIN() function. Next, we also pass the 100 to the MIN() function as the second value of the list.
  • The function selects the minimum value from the list of passed values and assigns it to “Minimum Shipping Charges”.
  1. Click on the “Check Syntax” button to validate the formula and ensure that there is no error.
    • 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.
MIN() Function in Salesforce
  1. Select the relevant Field Level Security. In this case, I have checked the “Visible” checkbox, so it is visible to all profiles. Then, to proceed, click on the “Next” button.
Calculate minimum value in Salesforce Lightning Example
  1. Now, select the appropriate Page Layout where we want to be visible. Click on the “Save” button to save the formula field.
  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 “Shipping Charges” field.
    • After saving, it will redirect to the Details Section, and here the “Minimum Shipping Charges” field appears, which shows you the result of the MIN() function.’
How to Calculate minimum value in Salesforce Lightning Example

As a result, we now know how to calculate the minimum value of a field in Salesforce.

Conclusion

With this, we have concluded that the MIN() Function in Salesforce is a great and efficient way to find the minimum value in a list. In addition, we focused on the syntax and various real-world business-related examples of the MIN() Function.

Furthermore, we covered the process of calculating the minimum value using the MIN() 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.