In this Salesforce tutorial, we will **learn the** **LN Function and** **how we can use it for calculating** **natural logarithmic value**. Moreover, we will focus on the **syntax of the** **LN() function** and **some** **practical examples for implementation**.

While working in the organization I got a task to predict future prices based on the historical price of the sales data and I have to complete this task using the Salesforce tool.

As a solution, I found that there is an **LN() function** in the salesforce that helps in the prediction of the future price of the sale. So, if you’re looking to discover **how to calculate the natural logarithmic value using Salesforce Lightning and Salesforce Classic, you’ve come to the right place.**

## What is LN() Function in Salesforce

There are multiple functions available in Salesforce that are used to perform mathematical calculations and one of them is **LN() functions**. This function is used to find out the natural logarithmic of a specific number.

In addition, this natural logarithmic is based on the constant e value and here e value is equal to 2.71828182845904. And the syntax of the **LN() function** in Salesforce is as given below:

`LN(number/field/formula)`

The value for which we try to calculate the natural logarithmic value is the value of the **number/field/formula** parameter. The parameter’s value may take the form of a field, a fixed value, or a complex formula.

To deeply understand the concept, let’s see an example:

As I have discussed above that I got a task to find **“Future Price”** and for this, I will use the **LN()** **function** of Salesforce. Here, is the formula:

`ln(Price__c)`

With this, we have learned the LN() function syntax, logic, and example.** **Now letâ€™s move ahead and learn how to calculate the natural logarithmic value in Salesforce Lightning.

## Calculating natural logarithmic value in Salesforce Lightning

The steps to calculate the natural logarithmic value in Salesforce Lightning:

**Step 1: **Log in to **Salesforce Lightning** mode, then click on the **“Gear Icon”** located in the top right corner of the page. To proceed, select** “Setup”** from the dropdown menu.

**Step 2:** From the menuâ€™s left side, click on **“Object Manager”**.

**Step 3:** Now, search for the object for which you want to use the** LN()** function in the search bar. As I want to track future orders, in this example, I look up the **“Order”** object.

**Step 4:** Click on the **“Order”** object, and it will redirect to the order page.

**Step 5:** From the menu on the left-hand side of the page, click on **“Field and Relationship”**.

**Step 6:** To create a formula field where we will use the **LN()** function, click on the **“New”** button.

**Step 7:** Now, it redirects to the **“Choose the field type”** page. Here, select the **“Formula” **as the data type by checking the radio button next to it.

**Step 8: **To proceed, click on the **“Next”** button.

**Step 9:** After entering the **“Field Label”** for the formula, the **“Field Name”** will be filled in automatically. In this instance, I entered **“Future Order”** as the field label.

**Step 10: **Select the **“Data Type”** for the field on which we want to apply the **LN() function**. In this case, I choose the **“Number”** as the formula return type and also set its **“Decimal Value”** to **2**.

**Step 11: **Click on the **“Next”** button to proceed to the next step.

**Step 12:** To compute **“Future Order”** by using the **LN()** formula, enter the formula in the advanced formula editor. The formula is as follows:

`5 * LN(Time_Period__c) + 2`

Here, we find out the natural logarithmic value of the custom field **“Time_Period__c”** using the **LN() function** in Salesforce. Then, we multiply the resultant value with the constant value 5 and finally add the whole result value to the constant value 2.

**Here, **Time_Period__c** is of number data type and here we add time period in days.

**Step 13:** To make sure that there is no mistake in the formula, click on the **“Check Syntax”** button.

**Step 14:** Optionally, we may define the **“Description”**, **“Help Text”**, and as well as **“Handle the empty field”** if you like.

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

**Step 16:** Select the appropriate **“Level Security”** option. In this case, I have selected the **“Visible”** checkbox as I want it to be visible to everyone. Then, click on the **“Next”** button from the menu.

**Step 17:** Now, choose the **“Page Layout”** that will display your content.

**Step 18:** To save the advanced formula field, click on the **“Save”** button.

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

- Open the Order
**Tab**and create a new order with the field**“Time”**. - After that, click on the
**Details**section, and here the**“Future Order”**field appears which shows you the result of the**ln() function**.

As a result, we now know** **how to calculate the natural logarithmic value in Salesforce Lightning. Now, weâ€™ll look at how to calculate the natural logarithmic value in Salesforce Classic.

Read MAX() Function in Salesforce | Calculate maximum value of field in Salesforce

## Calculating natural logarithmic value in Salesforce Classic

The steps to calculate the natural logarithmic value in Salesforce Classic:

**Step 1:** Open your Salesforce Classic edition from the Salesforce Lightning. Click on the **“Switch to Salesforce Classic”** by selecting **“Avtar”** first.

**Step 2:** Then select **“Setup”** from the menu.

**Step 3:** Scroll down to the **“Build”** section. Then under **“Customize”**, select the object for whom field we want to use the **LN() **function. In this instance, I use the **“Future Lead”** object because I want to monitor the possibility of future leads.

**Step 4:** Click on the **“Leads”** dropdown and select the **“Fields”** option to create a new formula field.

**Step 5:** Now move to the** “Custom Fields & Relationships”** and click on the **“New”** button to start the process of creating a new custom field.

**Step 6:** After this, you will be redirected to the **“Choose the field type”** screen on which you have selected the data type for the field. Here, I choose the **“Formula”** as the data type of the field by checking the radio button next to the data type.

**Step 7:** Click on the **“Next” **button to move to the next proceeding step.

**Step 8:** Enter the **“Field Label” **for the formula and the unique **“Field Name”** will be filled out automatically. In this example, I specify the **“Future Lead”**.

**Step 9:** Choose the **“Data Type”** for the field where we are going to calculate the future lead using the LN function. In this case, I select the **“Number”** as the formula return data type by clicking on the radio button in front of it.

**Step 10:** Click on the** “Next”** button to proceed to the next step.

**Step 11:** Go to the advanced formula editor and type the formula to compute the natural logarithmic value using the** LN() function**. In this example, I want to use the **LN()** function to compute the natural logarithmic of the future leads.

The formula is as follows:

`10 * LN(Time_Period__c +1) +2`

Here, we find out the natural logarithmic value of the custom field **“Time_Period__c”** and plus 1 to it using the **LN() function** in Salesforce. Then, we multiply the resultant value with the constant value 10 and finally add the whole result value to the constant value 2.

**Step 12:** Select **“Check Syntax” **to review the formula and ensure there are no errors.

**Step 13:** If weâ€™d like, we may specify the **“Description”** and **“Help text”** as well as **“Handle the empty field”**.

**Step 14:** To proceed, click on the **“Next”** button.

**Step 15:** Choose the appropriate **“Field Level Security”**. Because I want it to be visible to everyone, I have chosen **“Visible”** in this instance. Select **“Next”** to continue after that.

**Step 16:** Next, choose the suitable **“Page Layout” **for the area where we wish to display this field.

**Step 17: **In order to save the formula field, click the **“Save”** button.

Once weâ€™ve established the formula field, we may use it. Letâ€™s examine an illustration:

- Create a new lead with the field
**“Time”**by opening the**Lead**tab. - When we click
**Save**, we are taken to the**Detail Page**, where the**“Future Leads”**field displays the**LN() function**output.

As a result, we now know** **how to calculate the natural logarithmic value in Salesforce Classic.

## Conclusion

In a nutshell, we have learned about the **LN() function in Salesforce** with its syntax and real-life examples. In addition, we learned the steps to calculate the natural logarithmic value in Salesforce Lightning and Salesforce Classic.

You may like to read:

- GEOLOCATION() Function in Salesforce | Calculate geolocation in Salesforce
- LOG() Function in Salesforce | Calculate logarithmic value in Salesforce
- MIN() Function in Salesforce | Calculate minimum value in Salesforce

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.