Calculated fields in Pipeliner can be used for numerical calculations — e.g. the calculation of a Commission Amount based on a percentage of the Opportunity value — and also for “**Scoring**” fields where the calculation is based on values selected by your users in custom dropdown fields — e.g. the Opportunity Score field shown which is calculated from the values selected in the “**Strength of Influence**”, “**Personality**”, “**Knowledge**” and “**Interest Level**” fields. This article will show you how to create both types of calculation.

## Enabling Calculations in Fields

Enter the Admin Module — from the Pipeliner CRM Application, click on the "**App Switcher**" icon in the top left corner ⤵

*NOTE: **Only users based on an Administrator role will see the Administration menu*

Select the "**Fields & Forms**" Menu Item. Next from the top of the page select the entity you would like to work with. In this article we will work on Opportunities but you use the exact same principles working with any other entity ⤵

Click on your field *(or create it if it doesn’t already exist).**See this article for instructions*** if you haven’t created custom fields before **⤵

Tick the “**Make this field calculated (using formula)**” box.

*NOTE:** if you don’t see this checkbox option, your field cannot be enabled as a calculated field (see Field Types earlier in this article).*

Once you’ve enabled this option, the Calculated Formula box will display and below it will be a list of the fields that you can base your calculation formula on ⤵

#### Which field types can be set as Calculated Fields?

You can enable calculations within the Field Properties for *Integer Number*, *Float Number*, *Base Currency* and *Multiple Currencies* fields.

*NOTE:** all currency calculations are based on the system base currency only — it is not possible to select the currency in a calculated field. For this reason, it’s best to always use Base Currency type fields when you intend to enable a calculation.*

*NOTE:** when enabled as a Calculated Field, the calculation is applied across all forms that the field is used on. This is particularly relevant for Opportunities where you have different forms per pipeline. Specifically, this means that if you enable the Opportunity Value field as a Calculated Field, the same calculation will be used in each of your pipeline Opportunity Forms — there is no way to set different calculations per form.*

#### EXAMPLE — Calculating Commission Amount

We want to create a formula that calculates the "**Commission $**" for a deal as a percentage of the *Opportunity Value*.

**There are options as to how to set this up and the method you choose will depend on how you want to work:**

#### Option #1 — User inputs Commission Percentage into number field

This will work for you if you want your users to fill in the Opportunity Value and also type a number into the Percentage Commission field. The Commission Percentage value could be a full number *(if you’ve created an Integer Number field)* or include decimals *(if you’ve created a Float Number field)*.

*FORMULA:** If this is your setup, the formula will be Opportunity Value x Commission Percentage/100*

This is how it would look in the "**Field Properties**" ⤵

#### Step by Step Instructions

Search for the "**Opportunity Value**" field by name in the search box below “**Fields available for calculation**” and click on the "**+**" beside the "**Field ID**" number to add it to your formula ⤵

*NOTE:** you can search by partial name*

Click into your formula field and type in the asterisk *(multiplication symbol) *⤵

*NOTE:** You’ll get a warning that “**Formula is incorrect due to bad syntax**”. This will disappear when your formula is correct and valid.*

Make sure the cursor in the "**Calculated Formula**" box is flashing AFTER the asterisk you just typed in and then search for your *Commission Percentage* field in the search box and click on the "**+**" to add it to your formula ⤵

*NOTE:** the incorrect formula warning has now disappeared as this formula is correct and valid (though incomplete in our scenario)*

Click into the *Calculated Formula* box and add the "**/100**" at the end of the formula to complete it ⤵

Click on "**Save**".

Next make sure you have placed your *Percentage Commission* and your *Commission Amount* fields on the *Opportunity Form* and then "**Publish**" your changes.

Here’s how it looks on the *Opportunity* in the Pipeliner CRM App ⤵

The user has typed "**12**" in the *Commission Percentage *field and the *Commission Amount* has been calculated as "**£240**".

*BUT...*

If the user types "**0.12**" instead of the "**12**" that we are expecting, our formula will be wrong as it will calculate the *Commission* as "**£2.4**".

*So here’s an alternative solution that can eliminate this type of data entry problem.*

#### Option #2 — User selects the Commission Percentage from a custom dropdown

When you create a custom dropdown field in Pipeliner, as you add values into your list, the second column contains a number. By default this auto-completes, incrementing by one for each additional text value that you add. This number can be changed and can be accessed in calculations...

So, in this example, I’ve created a dropdown field for "**Commission %**" and changed the numbers associated with each entry in my list to represent the numerical value that I want to use in my formula for *Commission Amount *⤵

*FORMULA: **the formula will now be *** Opportunity Value x Commission % **⤵

This approach takes a bit more work on the Admin side but eliminates problems with users typing the wrong number into your field!

And here’s what it looks like in the App ⤵

#### EXAMPLE — Opportunity Score

You can use this ability to assign a numerical value to a text selection in a custom Dropdown field to set up “**Scoring**” fields.

*NOTE:** The most common scenario is Opportunity or Lead Scoring based on the values entered in a number of “qualification” fields.*

This is an example of how this set up would look on the *Opportunity Form *⤵

As a user selects different values in the dropdown fields the score updates.

This is the set up for one of those fields, “*Strength of Influence*” ⤵

So when a user selects “*Weak*”, *One (1)* is added to the score but when the user selects “**Strong**”, *Ten (10)* is added.

#### Which operations can be used in formula?

#### EXAMPLE — How to eliminate “DIVIDE BY ZERO” errors

If you’ve set up a formula which includes one field divided by another, if your users don’t fill in the second field, they’ll get a “**DIVIDE BY ZERO**” error message when making any changes to the record.

In this example, I’ve created a “**Number of Months**” Integer Number field *(I only want whole months)* and a Monthly Amount Base Currency Field. I want to calculate Monthly Amount as Opportunity Value/Number of Months. If my users don’t complete the Number of Months field, this is the error that will come up ⤵

You could set the Number of Months field as “**required**” but that’s often not what you want to do as it would mean that no opportunity could be saved without that field being filled in.

Instead, we can adapt our formula to accommodate an empty field by using an IF statement. As you’ll see from the table above, when using an IF statement, the format of your formula must be *IF(logical_expression, value_if_true, value_if_false)*. For our example, we want to only calculate the "**Monthly Amount**" when "**Number of Months**" is filled in and if it isn’t, set "**Monthly Amount**" to zero. We can achieve this using a formula as shown below:

*FORMULA:** IF (“Number of Months”>0, Opportunity Value/Number of Months,0)*

And this is how it looks when enabled for the "**Monthly Amount**" field ⤵

And here’s another way of achieving the same result by using the "**ISEMPTY**" function rather than "**>0**".

*FORMULA:** IF(ISEMPTY(“Number of Months”, 0, Opportunity Value/Number of Months)*

*NOTE:** this time the 0 value assigned to Monthly Amount is inserted if it’s TRUE that Number of Months is empty and the calculation Opportunity Value/Number of Months applied when FALSE i.e. filled in.*