In this Salesforce tutorial, we will learn how to use the ATAN2() function in Salesforce to determine the arc tangent quotient value of the numerical data. We will also learn its syntax and a few useful examples.
Recently, I got hired by a multinational company located in California and they make use of Salesforce as a CRM application. One day I got the task of determining the campaign success score.
So, as a solution, I found that Salesforce provides the function named ATAN2() which helped me to calculate the success rate of the campaign.
If you want to learn how how to use the ATAN2() function to calculate the arc tangent quotient value using the Salesforce Lightning and Salesforce Classic components let’s deep dive into this tutorial and learn with examples.
ATAN2() Function in Salesforce
The ATAN2() function is one of the many mathematical functions available in Salesforce that may be used to carry out trigonometry mathematical calculations. The ATAN2() function is short for “arc tangent 2” in Salesforce.
Basically, we use this ATAN2() function to find out the inverse tangent of the quotient value of y and x in radians. It only supports numeric data types like Decimal, Currency, and Integer. And if we try to use text, dates, or other non-numeric data types, it will produce an error.
Below is the syntax for the ATAN2() function in Salesforce:
ATAN2(y, x)
Here, y and x stand for the points y and x value/field/formula respectively. And the resultant value is returned by the function in radians.
Let’s look at an example to better understand the ATAN2() function concept and syntax.
As I have discussed above that I got a task to find the success rate of the campaign and for this, I will use the ATAN2() function of Salesforce. Let’s see the formula for this:
ATAN2(No_of_Conversion__c, No_of_Lead__c) * 100
With this, we have learned ATAN2() function syntax, logic, and demonstration. Now, let’s move ahead and learn the difference between the ATAN and ATAN2 functions of Salesforce.
Difference between ATAN() Function and ATAN2() Function in Salesforce
The following are the difference between the ATAN() function and ATAN2() function in Salesforce:
Basics | ATAN() Function | ATAN2() Function |
---|---|---|
Description | The Salesforce ATAN() function returns the arc tangent of a passed parameter. | The Salesforce ATAN2() function returns the arc tangent of the quotient of two passed parameters. |
Parameters | number – The input number | y – The y-coordinate, x – The x-coordinate |
Return Type | ATAN() function return the resultant value in radians. | ATAN2() function return the resultant value in radians. |
Read TEXT() Function in Salesforce
How to use ATAN2() Function in Salesforce Lightning
The following are the steps to use the ATAN2() function in Salesforce Lightning.
Step 1: Open Salesforce Lightning mode. Next, click the “Gear Icon” in the top right corner of the page. Click “Setup” from the dropdown menu to continue.

Step 2: The setup page is opened after selecting the Setup option. Here, the “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.

Step 3: The object manager page is opened after you click it. There are numerous objects seen here. Use the quick find search field to look for the item on which we want to use the ATAN2() function. In this instance, I look for the “Order” object because I need to determine how quickly orders are shipped and placed.
Step 4: Now click the “Order” object to move to the Order object page.

Step 5: Under this order object page, on the left side of the page, the “Field & Relationship” option is found in the details section. Select “Field & Relationship” from the menu.
Step 6: The field and relationships page is opened after selecting the field and relationship option. Click the “New” button at the top of the field and relationship page.

Step 7: The field type page is opened after clicking the new button. The page contains a wide variety of field types. In this case, I choose the “Formula” field type field, as I want to use the ATAN2 function in the advanced formula.
Step 8: Click the “Next” button to move on to the next step.

Step 9: The choose output type screen appears after clicking the next button. Enter the information now by filling out the “Field Label” and the “Field Name”, which is automatically filled in when you put the cursor on the field name. In this instance, I typed “Delivery Efficiency” into the field label.
Step 10: Choose the “Output Data Type” for the field in which we want to store the result. In this case, I check the radio button in front of the “Number” data type to receive the formula return type as a number, and I also set the “Decimal Place” to 0.
Step 11: Move to the next, click on the “Next” button.

Step 12: Go to the advanced formula editor and enter the ATAN2() function formula there. In this instance, I want to use the ATAN2 function to calculate how quickly orders are shipped and placed. The formula is as follows:
ATAN2(Shipped_Orders__c, Placed_Orders__c) * 100
This formula calculates the delivery efficiency by dividing the shipped orders by the orders placed using the ATAN2 function.
Step 13: To validate the formula and make sure there are no mistakes, click the “Check Syntax” option.
Step 14: Optionally, we may define the “Description” and “Help text” as well as “Handle the empty field” if we like.
Step 15: Click on the “Next” button to go to the security setup for the formula field.

Step 16: In this step, establish “Field-Level Security”. Now choose the profiles to which we wish to grant field-level security edit access to this field. If field-level security is not added, the field will be hidden from all profiles.
Because I want it to be visible to all profiles, I have chosen “Visible” in this instance. After that, click the “Next” button located at the top.

Step 17: Add the custom field to the “Page Layout” after setting up the field-level security. Pick the page layout that has this field in it. If we do not select a layout, the field will not appear on any pages.
Step 18: To save the formula field, click the “Save” button.

We can use the formula field once we have created it. Let’s look at an example:
- Open the Orders Tab and create a new order with the fields Shipped Orders and Placed Orders.
- The Delivery Efficiency field, which displays the output of the ATAN2() function, then appears when you click on the Details Section.
As a result, we now understand how to use the ATAN2 function in Salesforce Lightning. Now, we will look at how to use the ATAN2 function in Salesforce Classic.
Read TRUNC() Function in Salesforce
How to use ATAN2() Function in Salesforce Classic
The following are the steps to use the ATAN2() function in Salesforce Classic.
Step 1: Log in to your Salesforce account first, after you are logged in, the Salesforce Lightning Edition should already be open. Click “Profile Picture” once you are in Salesforce Lightning. The drop-down menu for the profile photo is available. There is a “Switch To Salesforce Classic” option below the selection of profile picture. Click on it.

Step 2: Next, click on the “Setup” option from the menu.

Step 3: The setup page is opened after selecting the setup option. Go down to the “Build” section now. Select the object for whose field we want to use the ATAN2() function under the “Customize” dropdown. In this instance, I choose the “Product” object since I need to determine the revenue growth of the product.
Step 4: Select “Products” from the drop-down menu. The drop-down list is available, and under it, there is a field option. Select “Fields” from the menu.

Step 5: The product custom field page is opened after selecting the fields option. There is a section titled “Product custom field and relationship” at the bottom of the page. Simply click the “New” button to add a new field.

Step 6: The field type page is opened after clicking the new button. The page contains a wide variety of data types. In this case, I am choosing the “Formula” data type field.
Step 7: Click the “Next” button to move on to the following step.

Step 8: The “Choose Output Type” window appears after selecting the next button. Fill out the “Field Label” and “Field Name” (which are pre-filled when you click on the field name) to enter the information. In this case, I entered “Revenue Growth” into the field label.
Step 9: Choose the “Output Data Type” for the field in which we want to store the result. In this case, I check the radio button in front of the “Currency” data type to receive the formula return type as a currency, and I also set the “Decimal Place” to 3.
Step 10: Click the “Next” button to move on to another step.

Step 11: Next, enter the ATAN2() function formula in the advanced formula editor. In this case, I wish to utilize the ATAN2 function, to calculate the revenue growth of the product. The formula reads as follows:
ATAN2(Current_Revenue__c - Previous_Revenue__c, Previous_Revenue__c) * 100
This formula determines the growth of product revenue by dividing the difference between the current and previous revenue by the previous revenue using the ATAN2 function.
Step 12: Click “Check Syntax” to validate the formula and ensure there are no errors.
Step 13: Define the “Description” and “Help text” as well as “Handle the empty field” if you would like.
Step 14: To access the security page for the formula field, click the “Next” button.

Step 15: Establish “Field-Level Security”. Select the profiles to whom you want to grant field-level security editing access. The field will be hidden from all profiles if field-level security is not set.
I have selected “Visible” in this case because I want it to be visible to all profiles. In order to continue, click the “Next” button at the top.

Step 16: After configuring the field-level security, add the custom field to the “Page Layout”. Choose the page layout that includes this field. The field would not show up on any pages if we choose not to select a layout.
Step 17: To save the formula field, click the “Save” button.

Once we have established the formula field, we may use it. Let’s examine an illustration:
- Create a new product with the fields Current Revenue, and Previous Revenue by opening the Products Tab.
- Click on the Details section after that, and the Revenue Growth field will display the ATAN2() function output.

We now understand how to use the ATAN2() function in Salesforce Classic.
Conclusion
In conclusion, we have learned that the Salesforce function ATAN2() is helpful for handling numerical data and arc tangent quotient values.
We can also apply this function in a number of real-world scenarios, including “Price Book Discount”, “Case Response Time”, “Lead Conversion Rate”, etc.
Additionally, we completely understand the Salesforce ATAN2() function syntax and approach for determining the arc tangent quotient value in both Salesforce Lightning and Salesforce Classic.
You may like to read:
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.