In this Salesforce tutorial, we will learn about the **Salesforce PI() function**. In addition, weâ€™ll learn the syntax and various real-world organization-based Salesforce examples for this function.

Recently, I was working for an American-based event management company that utilizes the CRM software Salesforce to manage its work. One day I got a task that required me to determine the number of circular stickers needed on the wall of the client’s cafe for decoration.

As a solution, I discovered that this Salesforce tool provide us with the function named **“PI”** which helps in determining the area and perimeter of the circular stickers without spending time on manual calculations.

So, If you want to understand **how to use the PI() function in Salesforce Lightning and Salesforce Classic**, letâ€™s go into further depth and explore.

## What is PI Function in Salesforce

The** PI() function** in Salesforce is the mathematical function available in Salesforce that is used to carry out mathematical calculations. In basic terms, the **PI() function** returns the pi value or we can say the mathematical constant Pi.

In addition, only numerical data types like **Integers**, **Decimals**, and **Currency** are supported by the PI() function. However, if you attempt to use a text, date, or other non-numeric data type, an error will result.

### Syntax and Usage of PI Function in Salesforce

The syntax of the PI function is as follows:

`PI()`

Here, in the **PI() function** we do not need to pass any parameter. If you pass any of the parameters to a function, it results in the error **“Incorrect number of parameters for function ‘PI()’. Expected 0, received”**.

For a better understanding of how the PI() function works, letâ€™s look at an example.

As I mentioned above, I need to figure out how much area and perimeter of the circular stickers I need to decorate the wall. So, therefore I utilize the Salesforce PI() method for this. The formula is as follows:

`(Wall_Area__c / (PI() * (Radius__c * Radius__c)))`

With this, we learned the syntax of the PI() function as well as an example. Weâ€™ll now look at how to use the PI() function in Salesforce Lightning.

## How to use PI Function in Salesforce Lightning

The steps to use the PI() function in Salesforce Lightning are as follows:

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

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

**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 you want to use the **PI() function** on. In this instance, I look for the **“Contract”** object because I need to determine the penalty fee for canceling the contract early.

**4:** Now click the **“Contract”** object to move to the contract object page.

**5:** Under this contract 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.

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

**7:** The data type page is opened after clicking the new button. The page contains a wide variety of data types. In this case, I choose the **“Formula”** data type field, as I want to use the **PI function** in the advanced formula.

**8:** Click the **“Next”** button to move on to the following 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. In this instance, I typed **“Penalty Fee”** into the field label.

**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 **“Currency”** data type to receive the formula return type as a currency, and I also set the **“Decimal Place”** to **1**.

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

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

`(PI() * (Radius__c * Radius__c)) * Penalty_Rate__c`

- Here, we calculate the square value of the radius with the field
**“Radius__c”**. - Then, to get the total area of the circle we multiply the square value of the radius with the PI value which we get from the Salesforce
**“PI() function”**. - Finally, to get the total penalty fee we multiply the total resultant value with the penalty rate field value
**“Penalty_Rate__c”**.

**13: **To validate the formula and make sure there are no mistakes, click the **“Check Syntax”** option.

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

**15:** Click on the **“Next”** button to go to the security stage for the formula field.

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

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

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

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

- Open the
**Contract Tab**and create a new contract with the fields**Radius**and**Penalty Rate**. - The
**Penalty Fee**field, which displays the output of the**PI() function**, then appears when you click on the**Details****Section**.

As a result, we now understand **how to use the PI() Function in Salesforce Lightning.** Now, weâ€™ll look at how to use the PI() Function in Salesforce Classic.

Read Round() Function in Salesforce

## How to use PI Function in Salesforce Classic

The steps to use the PI() Function in Salesforce Classic are as follows:

**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 Classic. The drop-down menu for the profile photo is available. There is a **“Switch To Salesforce Classic”** option below this selection of profile pictures. Click on it.

**2:** Next, select **“Setup”** from the menu.

**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 PI() function under **“Customize”** after that. In this instance, I choose the **“Orders”** object since I need to determine the total cost of the circular-shaped item Pizzas that we ordered.

**4:** Select **“Orders”** from the drop-down menu. The drop-down list is available, and underneath it is a field option. Select **“Fields”** from the menu.

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

**6:** The data 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.

**7:** Click the **“Next”** button to move on to the following 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) to enter the information. In this case, I entered **“Total Cost”** into the field label.

**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 **2**.

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

**11:** Next, enter the **PI() function** formula in the advanced formula editor. In this case, I wish to utilize the PI function, to calculate the total cost of the circular shape item pizza. The formula reads as follows:

`PI() * (Radius__C * Radius__c) * Quantity__c * Item_Price__C`

- Here, we first calculate the square area of the radius value field
**“Radius__C”**. - Then, we use the
**PI() function**that gets the value of Pi. - Next, to get the area of the circular item in my case pizza, we multiply the square area of a circle with the value of Pi as
**“PI() * (Radius__C * Radius__c)”**. - After that, we multiplied that whole result or we can say the total area of pizza with the quantity as
**“PI() * (Radius__C * Radius__c) * Quantity__c”**to get the combined total area of quantity with an area of a circle item. - Finally, we multiply the whole result by the per-item price as
**“PI() * (Radius__C * Radius__c) * Quantity__c * Item_Price__C”**to get the total cost of the specified quantity of pizza.

**12:** Click **“Check Syntax”** to validate the formula and ensure there are no errors.

**13:** Define the **“Description”** and **“Help text”** as well as** “Handle the empty field”** if youâ€™d like.

**14:** To access the security page for the formula field, click the **“Next”** button.

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

**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 wonâ€™t show up on any pages if we choose not to select a layout.

**17:** 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 order with the fields
**Radius**,**Quantity**, and**Item Price**by opening the**Orders Tab**. - Click on the
**Details**section after that, and the**Total Cost**field will display the**PI() function**output.

We now understand how to use the PI() Function in Salesforce Classic.

## Conclusion

In conclusion, we have learned that the Salesforce PI() function is an effective way to obtain the pi value. Moreover, we have learned the PI() function syntax and a number of real-world business scenarios.

In addition, we also covered in detail the steps for using the PI() Function in 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.