Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Exploring Field Types – Part 2: Calculated Fields

Post Author: Joe D365 |

Welcome back to our two-part blog series on Field Types. In Part I of the series, we tackled Rollup fields – if you missed it, check it out here. In today's entry, we'll take it a step further and discuss Calculated Fields, including when and why to use them and how to add them. Let's get started…

Recall that in Part I, we assumed that we wanted to easily see the number of tasks against each opportunity, as well as how many of those tasks have been completed at any given time. To accomplish this, we created two rollup fields: Tasks
and
Tasks Completed. The result was a View that looked like this:

Calculated Fields

It allowed us to see that the "4G Enabled Tablets" opportunity, for example, required 9 pieces of effort (or, more familiarly, Tasks), of which only 3 had been completed. This is useful information, of course, but it would sure be nice to take it a step further…

Let's say that for each opportunity (or Topic), we want to quickly see the percentage of tasks completed and the number of tasks outstanding (after all, nobody should have to do all that math in their head). Luckily, it's just a matter of creating a couple new fields. Piece of cake!

First, let's define the math required to achieve our desired information:

% Completed = (Tasks Completed / Tasks) * 100

Tasks Outstanding = Tasks – Tasks Completed

Note that both formulas require that we know Tasks Completed and Tasks. It is no coincidence that those are exactly the two fields we created in PART I of this series! J OK, without further ado, let's get started.

Begin by creating the first of two more new Fields – in our example below, we've named it % Completed. Set "Data Type" to Decimal Number; set "Field Type" to Calculated, as shown:

Calculated Fields

Note in the screenshot above that the Schema automatically removes the "%" from the "Name" – but don't worry, because the "Display Name" (which is what we will eventually see in our View) retains the "%."

Click Edit (circled above) to modify the properties of the Calculated field.

You may recall that in Part I of this blog series (when we created two new fields: Tasks and Tasks Completed), we made a special note of the fact that we were including the word "Tasks" in the name of each new field. Well, here's where that comes in handy:

On the next screen, click in the action area (to the right of the equal sign) and start typing "Tasks." As you begin typing, all field names that match the text you've entered will appear, as shown below. How cool is that?

Calculated Fields

 

 

At this point, we want to define the actual calculation we want performed in the % Completed field. Earlier, we defined this as % Completed = (Tasks Completed / Tasks) * 100. So, simply double-click on new_taskscompleted from the available options – this will add the field name to the action area. Next, type "/." Then double-click on new_tasks to add it to the action area. Type "*100." Finally, add the necessary brackets. When you're done, it will look like this:

Calculated Fields

Note that adding a "CONDITION" is optional – in our example, none is needed since we want to apply the calculation to every Opportunity record without exclusion.

Next, we'll create the second of two new Fields – in our example below, we've named it Tasks Outstanding. Set "Data Type" to Whole Number; set "Field Type" to Calculated, as shown:

Calculated Fields

Click Edit to modify the properties of the Calculated field. Once again, begin typing "Tasks" in the action area to reveal the available fields.

At this point, we want to define the actual calculation we want performed in the Tasks Outstanding field. Earlier, we defined this as Tasks Outstanding = Tasks – Tasks Completed. So, simply double-click on new_tasks from the available options – this will add the field name to the action area. Next, type "-." Then double-click on new_taskscompleted to add it to the action area. When you're done, it will look like this:

Calculated Fields

Once again, note that adding a "CONDITION" is optional – in our example, none is needed since we want to apply the calculation to every Opportunity record without exclusion.

Next, we need add our two newly-created fields to our existing Section in the Form. (For more information, see Customizing Entities.)

Next, we need to add our new fields to a View, which is as simple as selecting the View and adding the columns. (For detailed information on how to do this, please see Customizing Views.)

Publish all changes. Unlike Rollup fields, which take up to 24 hours for the changes to be applied, Calculated fields are updated immediately. So, all your data is populated right away, as shown below:

Calculated Fields

Now, we can very quickly and easily see that the "4G Enabled Tablets" opportunity, for example, is 33.33% complete with 6 outstanding tasks. All the math is done for us! Pretty slick, no?

Well, that'll do it for Part II. Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

One comment on “Exploring Field Types – Part 2: Calculated Fields”

  1. Good reference to calculated fields. Would also add info on field limitations.

PowerObjects Recommends