EXP() Function in Salesforce | Calculate exponential value in Salesforce

In this Salesforce tutorial, we will learn the EXP() function and how we can use it for calculating the exponential value of numerical data. Moreover, we will focus on the syntax of the EXP() function and some practical examples for implementation.

While working in a company that uses Salesforce as a CRM tool. I got a task from the client to predict viral trends based on user engagement analysis.

As a solution, I discovered that EXP() function is a great tool to determine viral trends based on user engagement analysis. So, let’s move and learn the whole procedure of how to use Salesforce Lightning and Salesforce Classic components for using the EXP() function to determine the viral trend and in other scenarios also.

What is EXP() function in Salesforce

Numerous mathematical functions are available in Salesforce for performing mathematical calculations and EXP() function is one of them. This EXP() function is used to calculate the exponential value.

In addition, this EXP() 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.

Moreover, it returns the value e raised to the power of the numerical parameter we have specified.

Syntax and Usage of EXP() function in Salesforce

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

EXP(number/field/formula)

The value for which we are attempting to find the exponential is the value of the number, field, or formula parameter. The parameter’s value may be a field, a fixed numeric value, or an advanced formula also.

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

As I mentioned above, I was given the assignment to determine the “Predicted Viral Trend” and I will do this by using the Salesforce EXP() function. So, for this here is the complete formula that we apply in Salesforce.

Expected Viral Trend = Start_Trend__c * EXP(Growth_Rate__c * Time__c)

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

Read LOG() Function in Salesforce | Calculate logarithmic value in Salesforce

How to calculate the exponential value in Salesforce Lightning

Here, are the steps to calculate the exponential value 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”.

EXP Function in Salesforce

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

EXP Function in Salesforce Example

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

See also  How to Export Data from Salesforce

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

EXP Function in Salesforce Lightning

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 EXP() function.

EXP Function in Salesforce Lightning Example

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.

Calculate exponential value in Salesforce

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 exponential 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.

Calculate exponential value in Salesforce Lightning

Step 12: Move to the advance formula editor, and enter the formula that uses the EXP() function.

In this case, I want to calculate the reach of advertising campaigns using the EXP() function. Here, is the formula:

Audience__c * (1-EXP(Views__c))
  • Here, we take the “Audience__c” field that specifies the audience size and the “Views__c” field that specifies the already recorded number of views.
  • Firstly, we subtract the exponential value of the view from 1 that we get using the EXP() function.
  • Next, we multiply the result by the audience size and the final result shows the campaign advertisement’s reach to the audience.

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 next step.

Calculate exponential value in Salesforce Example

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.

See also  LEFT Function in Salesforce

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

Calculate exponential value in Salesforce Lightning Example

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

How to Calculate exponential value in Salesforce

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 “Audience” and “Views”.
  • After that, click on the Details section, and here the “Advertisement Reach” field appears which shows you the result of the EXP() function.
How to Calculate exponential value in Salesforce Lightning

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

How to calculate the exponential value in Salesforce Classic

Here, are the steps to calculate the exponential value 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.

EXP Function in Salesforce Classic

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

EXP 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 EXP() function. In this case, I select the “Leads” object as I want to track future sales.

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

Calculate exponential value in Salesforce Classic

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

Calculate exponential value 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.

Calculate exponential value using Salesforce Classic

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

Step 9: Select the “Data Type” for field that we want to calculate the exponential 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 2.

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

Calculate exponential value using Salesforce Classic Example

Step 11: Move to the advance formula editor, and enter the formula that uses the EXP() function to calculate the exponential value.

In this case, I want to calculate the future sale using the EXP() function. Here, is the formula:

Previous_Sales__cc * EXP(Growth__c * Time__c)
  • Here, we take the “Previous_Sales_cc” field that specifies the sales value in the previous time, the “Growth__c” field that specifies the growth in the sales, and the “Time__c” field that specifies the time period for which we want to predict.
  • Firstly, we multiply the growth rate of the sales by the expected time period and then pass the result to the EXP() function to get the exponential value.
  • Next, we multiply the previous sales by the resultant value, and as a result, we finally get the forecasted value of the sales.
See also  Delete Custom Object Salesforce

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 field-level security step.

How to Calculate exponential value 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.

How to Calculate exponential value in Salesforce Classic

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.

How to Calculate exponential value in Salesforce Classic Example

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 “Previous Sales”, “Time”, and “Growth”.
  • On save, it will redirect us to the Detail page, and here the “Forecast Sales” field appears which shows us the result of the EXP() function.
How to Calculate exponential value using Salesforce Classic Example

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

Conclusion

With this, we have concluded that the Salesforce function EXP() is an excellent tool for handling numerical data. Additionally, we have learned how to calculate “Sales Forecasting”, “Product Growth”, “Social Media Engagement”, etc.

Furthermore, we have also understood the concept of the EXP() function its syntax, and the procedure for calculating the exponential value in Salesforce Lightning and Salesforce Classic.

You may also like to read the following articles: