{"id":132,"date":"2022-01-06T09:27:07","date_gmt":"2022-01-06T09:27:07","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=132"},"modified":"2022-01-06T09:27:08","modified_gmt":"2022-01-06T09:27:08","slug":"creating-a-simple-rollup-field","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/creating-a-simple-rollup-field\/","title":{"rendered":"Creating a Simple Rollup Field"},"content":{"rendered":"\n<p>Roll-up Fields in Dynamics allow us to perform a SUM or COUNT of Child Records that then \u2018rolls-up\u2019 to a Parent Record.<\/p>\n\n\n\n<p>The most obvious example of this could be a simple COUNT of the Number of Opportunities recorded in CRM for a particular Client \u2013 so we could then view a simple Number in the Account Form that would quickly inform us of the number of Opportunities.<\/p>\n\n\n\n<p>This then becomes doubly helpful in Reporting where we might then use the \u2018Count of Opportunities\u2019 Roll-up Field in our Reports based on the Account Entity.<\/p>\n\n\n\n<p>Here we will look at creating a basic Roll-up Field and see how this is done in Dynamics.<\/p>\n\n\n\n<p><strong>Scenario \u2013<\/strong>&nbsp;if we take the scenario where we want to be aware of any Opportunities in CRM that do not have any Open Tasks for Follow-up \u2013 then we could look at adding a Roll-up Field to COUNT the Number of Open Tasks for an Opportunity.<\/p>\n\n\n\n<p>This will then allow us to run an Advanced Find to find any Opportunities that have 0 Pending Tasks, and so the Opportunities that do not have any defined Next Steps.<\/p>\n\n\n\n<p><strong>Creating the Field \u2013&nbsp;<\/strong>first of all we add the Field to the Opportunity Entity as we would any other Dynamics Field \u2013 specifying Whole Number or a Decimal Data Type for the Field, as we will need a Data Type that is capable of the SUM or COUNT logic we want.<\/p>\n\n\n\n<p>But, before we save the Field into CRM, we select \u2018Rollup\u2019 as the Field Type:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"523\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-1.png\" alt=\"\" class=\"wp-image-134\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-1.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-1-300x196.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-1-768x502.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p><strong>Edit the Rollup Logic \u2013&nbsp;<\/strong>when ready with the Field, we can click EDIT to start defining the logic behind our Rollup Field.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Where are we rolling up from?&nbsp;<\/h3>\n\n\n\n<p>Our first step is to pick what Related Entity in CRM we want to roll-up from, this will be the Child Entity that we want to COUNT or in some way SUM into our Parent Record.&nbsp; In our example, this would be the Tasks regarding the Opportunity<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"330\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image.png\" alt=\"\" class=\"wp-image-133\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-300x124.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-768x317.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">How do we Filter our Roll-up?&nbsp;<\/h3>\n\n\n\n<p>Typically we will not want a simple COUNT but a COUNT based on a particular Filter \u2013 so in our example we would only want to COUNT Open Tasks so that we are not also including Closed Tasks in the Count.&nbsp; We would add this logic by specifying the Filter here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"507\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-135\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-2.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-2-300x190.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-2-768x487.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">What COUNT or SUM do we want to Roll-up?<\/h3>\n\n\n\n<p>As the final step in our Rollup Logic, we specify what calculation we want the Field to calculate from our Child Records and insert into the Parent.<\/p>\n\n\n\n<p>This can be a particular calculation on Fields in the Child Records to build reporting logic, or can be a simple COUNT of the records involved.<\/p>\n\n\n\n<p>In our example, we can simply define the Field to count the number of Tasks returned by our Filter for that Opportunity:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"490\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-3.png\" alt=\"\" class=\"wp-image-136\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-3.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-3-300x184.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-3-768x470.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>We can then save our new Field into CRM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Add to the Form and Publish<\/h3>\n\n\n\n<p>We can then open the normal Form Designer in Dynamics and position our new Field on the Form.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"656\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-4.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-4.png 640w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-4-293x300.png 293w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p>The Rollup Field will then (naturally enough for a calculated field) be presented as Read-Only, however this will also come with a Date Field for when the Rollup Calculation was last updated.<\/p>\n\n\n\n<p>Dynamics 365 will automatically calculate Rollup Fields every 12 hours as part of a system-wide refresh process; but we can also force a recalculation by clicking the Recalculate button.<\/p>\n\n\n\n<p>Rollup Fields give us basic calculations that can make the Form more useful to the User, but their power in CRM really comes into play when coupled with Views and Advanced Find to return groups of records based on this Calculated Field \u2013 to this end, we can use the Rollup Field as we would any other Field in the Advanced Find:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"270\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-5.png\" alt=\"\" class=\"wp-image-138\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-5.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-5-300x101.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-5-768x259.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Then calculates as:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"327\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-6.png\" alt=\"\" class=\"wp-image-139\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-6.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-6-300x123.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-6-768x314.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>This can then produce a Report of Opportunities that have multiple Follow-up Tasks in place, or particularly Opportunities which do not have a Follow-up Task in place .i.e. where our Rollup Field has calculated to 0.<\/p>\n\n\n\n<p>This ability to run a View on the presence of a negative can be quite difficult in Dynamics, and so the use of a Rollup Field in this instance allows us to produce this type of report more easily \u2013 so we can produce a report on our Open Opportunities that have no Follow-up Task recorded:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"283\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-7.png\" alt=\"\" class=\"wp-image-140\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-7.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-7-300x106.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-7-768x272.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Report as:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"267\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-8.png\" alt=\"\" class=\"wp-image-141\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-8.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-8-300x100.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-8-768x256.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Giving us a handy use for our Roll-up Field in helping us manage Opportunities that need further Follow-up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Going one step further..<\/h3>\n\n\n\n<p>As we see here Rollup Fields can do basic calculations and aggregations \u2013 however we expand on this and look at MAX and MIN operations within a Rollup Field.<\/p>\n\n\n\n<p>When combined with looking at a Date Field this can be used to find the most recent record in the past or future, and this gives a handy tool for not just tracking the number of Tasks for an Opportunity but also the Last Completed Task as the last follow-up to that Opportunity.<\/p>\n\n\n\n<p>For this, we customise a new Roll-up Field as:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Rollup all Regarding Tasks<\/li><li>Where the Task is Completed<\/li><li>Calculate as the MAX of the Task\u2019s Actual End<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"477\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-9.png\" alt=\"\" class=\"wp-image-142\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-9.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-9-300x179.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-9-768x458.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>This will then give us the last Follow-up Date for each of our Opportunities which we can add into our Views and Advanced Finds:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"247\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-11.png\" alt=\"\" class=\"wp-image-144\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-11.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-11-300x93.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-11-768x237.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>We can similarly implement a Next Scheduled Follow-up Date field in the same way:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Rollup all Regarding Tasks<\/li><li>Where the Task is Open \/ Active<\/li><li>Calculate as the MIN of the Task\u2019s Due Date<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"467\" src=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-10.png\" alt=\"\" class=\"wp-image-143\" srcset=\"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-10.png 800w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-10-300x175.png 300w, https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2022\/01\/image-10-768x448.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>This builds us a simple system of tracking Last, Next and the Count of Follow-up Tasks for an Opportunity.<\/p>\n\n\n\n<p>This focuses particularly on Tasks associated to an Opportunity, but can be used with any Activity instead of just Task by using the Related Activity Relationship in CRM.<\/p>\n\n\n\n<p>This gives us a practical usage of Roll-up Fields that we can apply in our uses of Dynamics.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Further Reading on Roll-up Fields<\/h3>\n\n\n\n<p>The following articles give further information on using Rollup Fields in Dynamics 365<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Define rollup fields that aggregate values<\/strong><\/p><p><a href=\"https:\/\/docs.microsoft.com\/en-us\/dynamics365\/customer-engagement\/customize\/define-rollup-fields\">https:\/\/docs.microsoft.com\/en-us\/dynamics365\/customer-engagement\/customize\/define-rollup-fields<\/a><\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Dynamics 365 \u2013 Rollup Fields \u2013 Important Points<\/strong><\/p><p><a href=\"https:\/\/community.dynamics.com\/365\/b\/sachinbansalmicrosoft\/archive\/2018\/05\/07\/dynamics-365-rollup-fields-important-points\">https:\/\/community.dynamics.com\/365\/b\/sachinbansalmicrosoft\/archive\/2018\/05\/07\/dynamics-365-rollup-fields-important-points<\/a>&nbsp;<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Introducing Calculated and Rollup Fields<\/strong><\/p><p><a href=\"https:\/\/www.akaes.com\/blog\/ms-dynamics-crm-2015-understanding-calculated-and-rollup-fields\/\">https:\/\/www.akaes.com\/blog\/ms-dynamics-crm-2015-understanding-calculated-and-rollup-fields\/<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Roll-up Fields in Dynamics allow us to perform a SUM or COUNT of Child Records that then \u2018rolls-up\u2019 to a Parent Record. The most obvious example of this could be a simple COUNT of the Number of Opportunities recorded in CRM for a particular Client \u2013 so we could then view a simple Number in<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"post-132","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-crm"},"featured_image_src":null,"author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/132\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}