With Dynamics CRM 2015 now we have the ability to define Rollup Fields. This is a no-code approach to aggregating data across 1:N relationships.
The functionality is similar to what you would do in Excel. You can take advantage of SUM, MAX, MIN and COUNT.
Let’s look at a very simple example of calculating all open Cases on an Account.
On the Account configuration, add a new field called Total Open Cases. Define it as Whole Number, and of type Rollup. Click on the Edit button.
In the window that opens, define the logic for calculation.
Once done defining the Rollup field, add it to your Account form. Save and Publish your customization.
Open an Account with open Cases. You will see the newly added field. If the total is not updated, click on the refresh icon to force refreshing the calculation. By default these calculations are running async and they refresh hourly.
Now your total will reflect the number of related open Cases.