Dynamics CRM: How to Create Calculated Fields

Published: 27 April 2016

 

Calculated fields in a CRM solution let you automate manual calculations used in your business processes. A calculated field can contain values resulting from simple math or conditional operations using the data held in other fields. Sound tricky? Here we show you how to accomplish this using the Microsoft Dynamics CRM user interface.

To explain how it all works, we’ve covered some real world scenarios for common calculated fields, including:

  • Weighted Value on the opportunity
  • Days Open (calculating how long an opportunity has been open for)

How to Create a Calculated Field in Dynamics CRM

Weighted Values

To get started follow these steps:

1. Navigate to Settings > Customisations and select Customise the System.

2. Expand Entities and Opportunity tabs on the left-hand side. From here you’ll need to select Fields. To set up a new calculated field, click on the New tab within the main window.

3. Add the following values for the new field:

Display Name: Weighted Value
System Name: WeightedValue
Data Type: Currency
Field Type: Calculated

All other field properties can be left as default.

4. Select the Edit button that appears beside the field type. This will open up the attribute editor, which will enable us to define our calculation for our new field.

Condition – Here we can specify a criteria for when the calculated field can be run. In this example we want it to run all the time, so we will not specify a condition.

Action – This is where we can create our calculation for our field. Select the + sign to add the action.

For the Weighted Value our formula should be the following: Set Weighted Value to (Est. Revenue / 100) * Probability

In our example we are assuming the fields are already in the system. If they’re not you will need to add the fields in beforehand.

Select Save and Close.

You will be returned back to the field, select Save and Close once more.

5. Once the field has been added you’ll need to add the field to forms or views you want it to be displayed.

Here’s how it looks on an opportunity:

In the example above the Estimated Value of the Opportunity is £25,000.00 and the Probability is 80. From this, our calculated field for Weighted Value gives us £20,000.00.

Days Open

Here we’ll show you how to calculate the number of Days Open. This will be based on the number of days the opportunity the Status is Open based on the Created On date and Todays Date.

To get started follow these steps:

1. Navigate to Settings > Customisations and the select Customise the System.

2. Expand Entities and Opportunity tabs on the left-hand side. From here you’ll need to select Fields. To set up a new calculated field, click on the New tab within the main window.

3. Add the following values for the new field:

Display Name: Days Open
System Name: DaysOpen
Data Type: Whole Number
Field Type: Calculated
Format: None

All other field properties can be left as default.

4.  Select the Edit button that appears beside the field type. This will open up the attribute editor, which will enable us to define our calculation for our new field.

5. In this example we’ve set two conditions and two actions.

Condition – To obtain the number of Open Opportunities, we need to calculate number of days between Today and Created On. This means we only want to run this formula on Opportunities that have the Status = Open.

Action – This is where we can create our calculation for our field. Select the + sign to add the action. The calculation for this should be as follows:

DIFFINDAYS(createdon, NOW())

What this means:

DIFFINDAYS() – Calculates the difference in days between two date fields

NOW() – Identifies the current date and time

By using these two functions together we’re able to find out the number of days an Opportunity has been “Open”.

Select Save and Close.

You will be returned back to the field, select Save and Close.

Once the field has been added you’ll need to add the field to forms or views you want it to be displayed.

In the example above, you can see the Opportunity want Created On 30/03/2016 and Today’s Date is 06/04/2016, showing the Opportunity has been open for 7 days.

Please Note: Calculated fields are read only

Read More