{"id":12260,"date":"2024-07-12T13:54:45","date_gmt":"2024-07-12T19:54:45","guid":{"rendered":"https:\/\/www.mrc-productivity.com\/techblog\/?post_type=ht_kb&#038;p=12260"},"modified":"2024-07-12T14:33:18","modified_gmt":"2024-07-12T20:33:18","slug":"working-with-duplicate-data-in-reports","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/techblog\/?ht_kb=working-with-duplicate-data-in-reports","title":{"rendered":"Working with Duplicate Data in Reports"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p>As a consultant, one of the most common scenarios I see is customers who have datasets with one-to-many relationships. <\/p>\n\n\n\n<p>To understand what a one-to-many-relationship is, imagine a m-Power Regular Report template with an order header table that is joined to an order line items table. At runtime, the report prints a row for every line item in the order, meaning the fields from the header record will be repeated (duplicated).<\/p>\n\n\n\n<p>Often times developers will opt to show or hide repeating data, and this is sufficient for their reporting needs. But what happens when a repeated value is <em>numeric <\/em>and needs to be counted only once for further subtotaling in the report? <\/p>\n\n\n\n<p>This techblog post will address that question and teach you how to address this situation via Freemarker.<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">If you are not familiar with Apache Freemarker, it is <strong>strongly <\/strong>encouraged to first read this documentation <a href=\"\/docs\/knowledge-base\/freemarker-overview\">here<\/a> to understand basic syntax and usage. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example Report<\/h2>\n\n\n\n<p>Observe the following tables, which have a one-to-many relationship.<\/p>\n\n\n\n<p>One header record in the ORDERHEAD table&#8230;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45a929e&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45a929e\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata1.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Figure 1. The first 10 rows of the Order Header table<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Is linked to multiple records in the ORDERDET table&#8230;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45a9576&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45a9576\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata2.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">Figure 2. The first 10 rows of the Order Details table<\/figcaption><\/figure>\n<\/div>\n\n\n<p>A report built over these two tables would net a result similar to what is shown in Figure 3. The report has the detail level, two subtotal levels, and a grand total (not shown).<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45a977d&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45a977d\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata3.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon\">The report is structured as such:<br><br>Detail Level<br>Subtotal Level 2 &#8211; Order Number (ONUM)<br>Subtotal Level 1 &#8211; Order Type (OTYPE)<br>Grand Total<\/p>\n\n\n\n<p>Observe the Order Amount column, which is a value from the header table. The amount is naturally repeated for any order with more than one line item and subsequently summed on the subtotal lines of the report.<\/p>\n\n\n\n<p>Using Order #300158 as an example, the order amount to print on the subtotal by order number line is $4,471. But because there are two line items for this order, the order amount sums to $9,482. <\/p>\n\n\n\n<p>To appropriate show $4,471 on the order subtotal, first we&#8217;ll go the Field Settings of the data model and specify the Order Amount&#8217;s aggregate option as &#8220;No Subtotal&#8221;. Once done, rebuild the report. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/techblog\/images\/duplicatedata6.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>While this appropriately gives the right amount wanted on the Total for #300158 and #301506 lines (Subtotal Level 2), it does not give the desired total on the &#8220;Total for EDI Orders&#8221; line (Subtotal Level 1). <\/p>\n\n\n\n<p>This is because as a &#8220;No Subtotal&#8221; value, the report just prints the order amount from the very last line item&#8217;s order amount which is $25,843.<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45a9cee&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45a9cee\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata4.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>The total amount for EDI orders ($30,584) will need to be summed behind the scenes and printed in that cell. <\/p>\n\n\n\n<p>$4,471 + $ 25,843 = <strong>$30,584<\/strong>. <\/p>\n\n\n\n<p>Using Freemarker, we will be able to do the summation in a custom variable. <\/p>\n\n\n\n<p>The idea here will be that every time we reach a subtotal by Order Number (subtotal level 2), we will add that order&#8217;s amount to the previous total. Once we reach the subtotal by Order Type (subtotal level 1) the summed value can be printed. The report will repeat this process until all the different orders subtotals lines and the order type subtotal lines have printed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<p>1. In the HTML source of the report, find the <code>&lt;!-- &lt;#list report as section&gt; --&gt;<\/code> comment. This is where the data table execution begins.<\/p>\n\n\n\n<p>2. Create a custom Freemarker variable above this comment, that will store the summed amount for subtotal level 1. In this example, that variable is called <strong><code>s1_amount<\/code><\/strong> and is initialized to a value of 0.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- END_SORT_TABLE_HEADER --&gt;\n&lt;!-- END_REPORT_TABLE_HEADER --&gt;\n<strong>&lt;!--&lt;#assign s1_amount = 0 &gt;--&gt;\n<\/strong>&lt;!-- &lt;#list report as section&gt; --&gt;\n&lt;!-- &lt;#assign lastRow = section.lastDetail&gt; --&gt;\n&lt;!-- &lt;#assign noSubtotal = section.lastDetail&gt; --&gt;<\/code><\/pre>\n\n\n\n<p>3. Further down in the HTML source, find the subtotal level 2 section. In this block add another assign statement that will add the current order amount (<code>lastRow.OAMOUNT<\/code>) to the current value of<code> s1_amount<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- &lt;#assign subTotal2 = section.subtotals&#91;2]> -->\n&lt;!-- &lt;#if subTotal2.dsp != 0> -->\n<strong>&lt;!--&lt;#assign s1_amount = s1_amount + lastRow.OAMOUNT_o >--><\/strong>\n  &lt;tr id=\"level_&#91;ONUM]\" class=\"level-row\">\n&lt;td class=\"rsd\" align=\"center\" colspan=\"5\">Subtotal Level 2 by &#91;ONUM]&lt;\/td>\n  &lt;\/tr>\n  &lt;tr class=\"sub2Background\" data-level=\"2\">\n    &lt;td class=\"s2 td_left\">&lt;\/td>\n    &lt;td class=\"s2 td_right\">Total for #${lastRow.ONUM?html}&lt;\/td>\n    &lt;td nowrap=\"nowrap\" class=\"\">&lt;\/td>\n    &lt;td class=\"s2\">&amp;nbsp;&lt;\/td>\n    &lt;td class=\"s2 text-right\">${lastRow.OAMOUNT?html}&lt;\/td>\n  &lt;\/tr>\n&lt;!--&lt;\/#if> --><\/code><\/pre>\n\n\n\n<p>Each time the report reaches a Subtotal Level 2 line it will loop through the above block of code and add the current subtotal line&#8217;s order amount (<code>lastRow.OAMOUNT_o<\/code>) to the previously stored total. <\/p>\n\n\n\n<p>Once each Subtotal Level 2 line has been looped through, the final total of <code>${s1_amount} <\/code>will known and can be printed on Subtotal Level 1.<\/p>\n\n\n\n<p>4. To reference a custom Freemarker variable, simply use the <code>${variablename}<\/code>in the HTML source, where &#8216;variablename&#8217; is whatever name given to your custom variable. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;td class=\"s1 text-right\"&gt;<strong>${s1_amount}<\/strong>&lt;\/td&gt;<\/code><\/pre>\n\n\n\n<p>From the m-Painter GUI, I can easily insert that value as well:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45aa0f1&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45aa0f1\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata5.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>5. While back in the HTML source, edit the Subtotal Level 1 section code. <strong>After <\/strong>the <code>s1_amount <\/code>has printed in the report, the value of<code> s1_amount <\/code>will need to be initialized back to 0. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- &lt;#assign subTotal1 = section.subtotals&#91;1]> -->\n&lt;!-- &lt;#if subTotal1.dsp != 0> -->\n&lt;tr id=\"level_&#91;OTYPE]\" class=\"level-row\">\n  &lt;td class=\"rsd\" align=\"center\" colspan=\"5\">Subtotal Level 1 by &#91;OTYPE]&lt;\/td>\n&lt;\/tr>\n&lt;tr class=\"sub1Background\" data-level=\"1\">\n  &lt;td class=\"s1 td_left\">Total for&amp;nbsp;${lastRow.OTYPE?html}&amp;nbsp;orders&lt;\/td>\n  &lt;td class=\"s1 td_right\">&amp;nbsp;&lt;\/td>\n  &lt;td nowrap=\"nowrap\">&lt;\/td>\n\n  &lt;td class=\"s1\">&amp;nbsp;&lt;\/td>\n  &lt;td class=\"s1 text-right\"><strong>${s1_amount}<\/strong>&lt;\/td>\n&lt;\/tr>\n<strong>&lt;!--&lt;#assign s1_amount = 0 >-->\n<\/strong>&lt;!--&lt;\/#if> --><\/code><\/pre>\n\n\n\n<p>5. Save m-Painter. <\/p>\n\n\n\n<p>6. The grand total value will also need to be computed in a similar fashion. This time, a new variable named <strong><code>grand_amount<\/code> <\/strong>will be created, right after the <code>s1_amount<\/code> variable. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- END_SORT_TABLE_HEADER --&gt;\n&lt;!-- END_REPORT_TABLE_HEADER --&gt;\n&lt;!--&lt;#assign s1_amount = 0 &gt;--&gt;\n<strong>&lt;!--&lt;#assign grand_amount = 0 &gt;--&gt;\n<\/strong>&lt;!-- &lt;#list report as section&gt; --&gt;\n&lt;!-- &lt;#assign lastRow = section.lastDetail&gt; --&gt;\n&lt;!-- &lt;#assign noSubtotal = section.lastDetail&gt; --&gt;<\/code><\/pre>\n\n\n\n<p>7. Further down in the HTML source, find the subtotal level 1 section again. In this block add another assign statement that will add the subtotal&#8217;s amount (<code>s1_amount)<\/code> to the current total (<code>grand_amount<\/code>).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- &lt;#assign subTotal1 = section.subtotals&#91;1]> -->\n&lt;!-- &lt;#if subTotal1.dsp != 0> -->\n<strong>&lt;!--&lt;#assign grand_amount = grand_amount + s1_amount >--><\/strong>\n&lt;tr id=\"level_&#91;OTYPE]\" class=\"level-row\">\n  &lt;td class=\"rsd\" align=\"center\" colspan=\"5\">Subtotal Level 1 by &#91;OTYPE]&lt;\/td>\n&lt;\/tr>\n&lt;tr class=\"sub1Background\" data-level=\"1\">\n  &lt;td class=\"s1 td_left\">Total for&amp;nbsp;${lastRow.OTYPE?html}&amp;nbsp;orders&lt;\/td>\n  &lt;td class=\"s1 td_right\">&amp;nbsp;&lt;\/td>\n  &lt;td nowrap=\"nowrap\">&lt;\/td>\n  &lt;td class=\"s1\">&amp;nbsp;&lt;\/td>\n  &lt;td class=\"s1 text-right\">&amp;nbsp;${s1_amount}&lt;\/td>\n&lt;\/tr>\n&lt;!--&lt;#assign s1_amount = 0 >-->\n&lt;!--&lt;\/#if> --><\/code><\/pre>\n\n\n\n<p>Each time the report reaches a Subtotal Level 1 line it will loop through the above block of code and add the current subtotal line&#8217;s order amount to the previously stored total. <\/p>\n\n\n\n<p>Once each Subtotal Level 1 line has been looped through, the final total of <code>${grand_amount}<\/code> will known and can be printed on the Grand Total level.<\/p>\n\n\n\n<p>8. Reference <code>${grand_amount}<\/code> on the Grand Total level of the report.<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45aa41d&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45aa41d\" class=\"wp-block-image size-large is-resized wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata7.png\" alt=\"\" style=\"width:668px;height:auto\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;td class=\"grand text-right\"&gt;<strong>${grand_amount}<\/strong>&lt;\/td&gt;<\/code><\/pre>\n\n\n\n<p>Save m-Painter again. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Results<\/h2>\n\n\n\n<p>Here I will show the report output. The first picture shows the report ran with details:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45aa6ae&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45aa6ae\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata9.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>The two EDI type orders total <strong>$30,584<\/strong> ($4,471+$25,843 = $30,584)<\/p>\n\n\n\n<p>The two FAX type orders total <strong>$27,958<\/strong>. ($27,003 + 954 = $27,958).<\/p>\n\n\n\n<p>Now, here is the same report without the Detail Level included:<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69f33c45aa8ea&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"69f33c45aa8ea\" class=\"wp-block-image size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"\/techblog\/images\/duplicatedata8.png\" alt=\"\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Enlarge\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>The Grand Total across all order types is <strong>$124,083<\/strong> ($30,584 + $27,958 + $36,883 + $28,656).<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use Freemarker to handle subtotaling in your report output. This example will walkthrough a report with a one-to-many join, and show how to specifically count duplicate detail records only one time. <\/p>\n","protected":false},"author":12,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[158],"ht-kb-tag":[],"class_list":["post-12260","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-customcode"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/12260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12260"}],"version-history":[{"count":39,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/12260\/revisions"}],"predecessor-version":[{"id":12306,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=\/wp\/v2\/ht-kb\/12260\/revisions\/12306"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12260"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fht-kb-category&post=12260"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/techblog\/index.php?rest_route=%2Fwp%2Fv2%2Fht-kb-tag&post=12260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}