In this Salesforce tutorial, we will learn how to use the **TAN() function in Salesforce** to determine the tangent value of numerical data. We’ll also concentrate on its syntax and a few useful examples.

Recently, I got hired by an American company that uses Salesforce as a CRM application. I was given the task of determining the performance of employee sales commissions.

I discovered the Salesforce TAN() function as a solution, which helped me calculate the performance metrics. Let’s now get more specific on how to use the TAN() function to calculate the tangent value using the Salesforce Lightning and Salesforce Classic components.

## What is TAN() Function in Salesforce

The **TAN() function in Salesforce** is one of the many mathematical functions available in Salesforce that may be used to carry out trigonometry mathematical calculations.

In addition, we use the **Salesforce TAN() function** to find out the tangent of an angle or value. It is mostly used in Salesforce when we need to find the radian value range between -PI/2 to PI/2.

Additionally, only numeric data types like decimals, currency, and numbers are supported by the TAN() function. And it will give us an error if we try to utilize text, dates, or any other non-numeric data types.

### Syntax and Usage of Salesforce TAN() Function

The Salesforce TAN() function syntax is given below:

`TAN(number/field/formula)`

The value for which we try to find the tangent is the value of the number/field/formula parameter. The parameter’s value may be a field, a fixed value, or a formula.

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

Let’s say I was given the task to determine the **“Productivity of the Employee”** and used the Salesforce TAN() function. Check out its formula:

`Employee Productivity = TAN((Actual__c - Target__c)/Target__c)`

We have learned TAN() function syntax, logic, and demonstration with this. Now, let’s move ahead and learn to determine the tangent value using the Salesforce Lightning Component.

## Calculate the tangent value in Salesforce Lightning using TAN() Function

The following steps to calculate the tangent value in Salesforce Lightning using the TAN() function.

**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. 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 items seen here. Use the search field to look for the item we want to use the TAN() function. In this instance, I look for the **“Order”** object to determine how quickly orders are sold and restocked.

**Step 4:** 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:** After selecting the field and relationship option, the field and relationship page is opened. Click the **“New”** button at the top of the field and relationship page.

**Step 7:** The data 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”** data type field, as I want to use the **TAN 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 **“Order Inventory”** into the field label.

**Step 10:** Choose the **“Output Data Type”** for the field where 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 **1**.

**Step 11:** Move to the next; click on the **“Next”** button.

**Step 12:** Go to the advanced formula editor and enter the **TAN() function** formula there. In this instance, I want to use the TAN function to calculate the order inventory. The formula is as follows:

`TAN(Sale_Amount__c / Average_Order__c)`

- To determine the order inventory, the formula divides the sale amount field value
**“Sale_Amount__c”**by the average number of orders field value**“Average_Order__c”**. - Then, the
**TAN function**is then applied to this resultant value to calculate the tangent, which shows how quickly orders are sold and restocked.

**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 stage 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. The field will not appear on any pages if we do not select a layout.

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

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**Sales Amount**and**Average Order**. - The
**Order Inventory**field, which displays the TAN() function output, then appears when you click on the**Details****Section**.

As a result, we now understand **how to calculate the tangent value in Salesforce Lightning.** Now, we will look at how to calculate the tangent value in Salesforce Classic.

Read ATAN2() Function in Salesforce

## Calculate the tangent value in Salesforce Classic

The following steps are to calculate the tangent value in Salesforce Classic using the TAN() function.

**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 profile picture selection. 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 TAN() function under the **“Customize”** dropdown. In this instance, I choose the **“Price Books”** object since I need to determine the change in the book price rate.

**Step 4: **Select **“Book Price”** from the drop-down menu. The drop-down list is available; under it, there is a field option. Select **“Fields”** from the menu.

**Step 5:** The price book custom field page is opened after selecting the fields option. A section titled “Price Books custom field and relationship” is at the bottom of the page. Simply click the **“New”** button to add a new field.

**Step 6:** The data type page is opened after clicking the new button. The page contains a wide variety of data types. I am choosing the “Formula” data type field in this case.

**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. I entered “Price Change” into the field label in this case.

**Step 9:** Choose the **“Output Data Type”** for the field where 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 **2**.

**Step 10:** Click the **“Next”** button to move on to another step.

**Step 11:** Next, enter the** TAN() function** formula in the advanced formula editor. In this case, I wish to utilize the TAN function, to calculate the price change of the books. The formula reads as follows:

`TAN(Current_Price__c - Previous_Price__c)`

- The formula (
**Current_Price__c**–**Previous_Price__c**) determines the difference between the current and previous book prices. - Then, the
**TAN function**is then applied to this resultant value to calculate the tangent, to represent the rate of change in book prices.

**Step 12:** Click **“Check Syntax”** to validate the formula and ensure 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:** Click the “Save” button to save the formula field.

Once we have established the formula field, we may use it. Let’s examine an illustration:

- Create a new price book with the fields
**Current Price**, and**Previous Price**by opening the**Price Book Tab**. - Click on the
**Details**section after that, and the**Price Change**field will display the**TAN() function**output.

We now understand how to calculate the tangent value in Salesforce Classic.

## Conclusion

In conclusion, we have learned that the **Salesforce function TAN()** helps handle numerical data and tangent value determination.

We can also apply this function in several real-world scenarios, including “Campaign Performance Evaluation”, “Lead Prioritization”, “Budget and Delivery Performance”, etc.

Additionally, we completely understand the Salesforce TAN() function syntax and approach for determining the tangent value in both Salesforce Lightning and Salesforce Classic.

You may also like:

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.