While working with Dynamics CRM there are times when you need to calculate some value using other fields and their values and then display the result on the form. For this type of customization CRM Users and Admins usually depend on CRM developers to implement these calculations trough code. However, there is another straightforward approach which does not require any technical knowledge or expertise in code: Calculated fields. Calculated fields are useful when we want to display calculated values based on other fields using calculation formula. Few examples are Cost of Labor, Contract duration, Net worth, etc.

There are out of the box formula function implementations like ADDHOURS, ADDDAYS, ADDWEEKS, ADDMONTHS, ADDYEARS, SUBTRACTYEARS, DIFFINDAYS, CONCAT, TRIMLEFT and TRIMRIGHT which you can use for Calculated fields but you can also write your own functions by using algebra operations.

Calculated fields can be used with following CRM data types:

  • Single Line of Text
  • Whole Number
  • Option Set
  • Two Options
  • Currency
  • Decimal Number
  • Date and Time

By following steps below you will learn how to use Calculated fields to calculate and display how many days have passed since contact has been created.

Step 1: Create Days Since Created field

On Form Customization screen click the New Field button

On the New Field screen set name to Days Since Created, Data Type to Whole Number and Field Type to Calculated. After this Save the field.

Step 2: Edit field calculation formula

After you have saved the field then go and click Edit button next to Field Type dropdown

Now replicate this formula and hit the Save and Close button

Save and close all other windows if available and reload Edit Contact Form screen.

Step 3: Add the field to Contact entity’s form

Find your new custom field in Field explorer and drag it somewhere on the form

After this go and save and close the form and then Publish All customizations.

Step 4: Open Contact record

When you open existing contact’s record you will see your field is displayed and calculated

 

As you can see this is done in just a few steps and you can apply this example to all sorts of fields and scenarios. For more info on Calculated fields you can read Microsoft’s article on the topic.