# ACOS() Function in Salesforce | Calculate inverse cosine value in Salesforce

In this Salesforce tutorial, we will learn about the ACOS() function and how we can use ACOS() function in Salesforce. In addition, we will also focus on its syntax and usage.

While employed in a Sales Organization that uses Salesforce as a customer relationship management tool to track their sales. I got a task to calculate the performance of the employees.

Here, I found an ACOS() function as a solution that helped me to calculate the performance metrics. Now, let us discuss in detail, how to use the ACOS() function to calculate the performance value of a number in Salesforce Lightning as well as Salesforce Classic.

## What is ACOS() function in Salesforce

In Salesforce, we have multiple functions that are used to perform mathematical calculations and the ACOS() function is one of the mathematical functions. Here, the ACOS() stands for “arc cosine”.

This ACOS() function is used to calculate the inverse cosine of a given angle or value. Primarily it is used in Salesforce when we perform trigonometric calculations or need a value in radians.

In addition, this ACOS() function always returns a positive value in radians or degrees and it ranges between 0 and pi in radians and 0 and 180 in degrees.

Moreover, we should be kept one thing in mind the ACOS() function works only on numeric data types such as Decimal, Integer, or Double. If you use it with other data types such as text, date, or other non-numeric data types it will produce an error.

## Syntax and Usage of Salesforce ACOS() function

The Syntax for the ACOS() function is given below:

``ACOS(number/field/formula)``

The number/field/formula parameter is the value for which we wish to determine the inverse cosine. The value specified in the parameter can be a field, a numeric constant, or a formula.

Let’s see an example to clearly understand the concept and syntax of the ACOS() function.

Suppose, we want to calculate the inverse cosine value of the numeric field value called “Satellite Dish” and for this, we use the ACOS() function and calculate it. The formula is as follows:

``ACOS(Target_Satellite_Latitude)``

With this, we have understood the ACOS() function with its syntax, consideration, and example. Now, we will move and try to understand the steps to calculate the inverse cosine value in Salesforce Lightning.

## Calculate the inverse cosine value in Salesforce Lightning

Here, are the steps to calculate the inverse cosine value in Salesforce Lightning:

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

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

3: Search for the object in the search bar where we wish to use the ACOS() function. In this case, I search for the “Opportunity” object as I want to track the sales opportunities.

4: Now, click on the “Opportunity” object and it will redirect us to the Opportunity Page.

5: From the left side of the page click on the “Field and Relationship” option.

6: Click on the “New” button to create a new formula field where we can use the ACOS() function.

7: It will redirect to the “Choose the field type” page, now check the radio button in front of the “Formula” data type.

8: To move ahead, click on the “Next” button.

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 “Commission Rate”.

10: Choose the “Data Type” for the field for which we want to calculate the inverse cosine value. Make sure the data type must be of a numeric type such as “Number“, “Currency“, etc.

Here, I check the radio button in front of the “Number” as I select it as the formula return type.

11: Now, to move to the next step click on the “Next” button.

12: Go to the advanced formula editor and input the formula to compute the inverse cosine value using the ACOS() function.

In this instance, I want to use the ACOS() function to determine the inverse cosine of the salesperson’s commission rate. The formula is as follows:

``IF(ACOS(SalespersonAngle) > 0.5, 0.15, 0.10)``
• In this formula, we calculate the salesperson commission rate using the inverse cosine ACOS() method.
• Then, we check if the angle is greater than 0.5 radians, the commission rate becomes 15% (0.15), otherwise, the commission rate is set to 10% (0.10).

13: Click on the “Check Syntax” button to validate the formula and ensure that there are no errors.

14: Optionally, we can “Handle the empty field” as well as we can define the “Description” and “Help text” if we want.

15: Click on the “Next” button to move ahead.

16: Choose the appropriate field “Level Security“. Here, I check the “Visible” checkbox as I want it to be visible to all. Then, click on the “Next” button.

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

18: Lastly, click on the “Save” button to save the formula field.

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

• Open the Opportunity Tab and create a New Opportunity with the field “SalespersonAngle”.
• After that, click on the Details section, and here the Commission Rate field appears which shows you the result of the ACOS() function.

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

Also, check out, COS() Function in Salesforce

## Calculate the inverse cosine value in Salesforce Classic

Here, are the steps to calculate the inverse cosine value in Salesforce Classic:

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

2: After that, click on the Setup option.

3: Now, scroll down to the Build section. Then under Customize, select the object for whom field we want to use the ACOS() function. In this case, I select the “Cases” object as I want to track customer satisfaction.

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

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

6: It will redirect to the “Choose the field type” page, now check the radio button in front of the “Formula” data type.

7: To proceed to the next step, click on the “Next” button.

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

9: Select the “Data Type” for field that we want to calculate the inverse cosine 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 “Number” to set it as the formula return type. I also set the decimal place to 2.

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

11: Move to the advance formula editor, and enter the formula that uses the ACOS() function to calculate the inverse cosine value.

In this case, I want to calculate the inverse cosine value of customer satisfaction based on customer feedback using the ACOS() function. Here, is the formula:

``ACOS(Feedback_Rating__c / 10)``

This formula calculates customer satisfaction using the ACOS() function. For this, we calculate the inverse cosine of the ratio by dividing the customer feedback rating by 10.

12: To check the formula and make sure there are no mistakes, click the “Check Syntax” option.

13: Optionally, we can define the “Description” and “Help text” as well as “Handle the empty field” if we prefer.

14: Click on the “Next” button to move ahead.

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.

16: Now, select the appropriate “Page Layout” where we want this field to be visible.

17: Lastly, click on the “Save” button to save the formula field.

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

• Open the Case Tab and create a New Case with the fields Feedback Rating.
• On Save, it will redirect us to the Detail page, and here the Customer Satisfaction field appears which shows us the result of the ACOS() function.