{"id":1399,"date":"2008-02-29T03:45:41","date_gmt":"2008-02-29T09:45:41","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/docs\/?page_id=1399"},"modified":"2023-09-14T10:49:35","modified_gmt":"2023-09-14T15:49:35","slug":"html-edit-codes-to-control-data-rounding","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/html-edit-codes-to-control-data-rounding","title":{"rendered":"Freemarker Edit Codes to Control Data Rounding"},"content":{"rendered":"\n<p>This documentation describes how to use Freemarker edit codes to hide decimals from view, while still allowing it to be used in calculating sub and grand total levels.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example Scenario<\/h2>\n\n\n\n<p>So that you can easily see the difference, a Regular Report application has been built with the dimension key set to the Customer State. Only one numeric field has been selected (Original Field). For comparison purposes, a calculation has been used to replicate this numeric field (Edited Field).<\/p>\n\n\n\n<p>Before any editing is done, my report output looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/dataRoundingBefore.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/dataRoundingBefore.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Since this requires HTML editing, we must open m-Painter.<\/p>\n\n\n\n<p>Right-click on your field at the detail level, and select &#8220;Cell&#8221; then &#8220;Edit Cell HTML&#8221;. Replace <code>?html}<\/code> with <code>_o?string(\"$,##0\")}<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/dataRoundingFM.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/dataRoundingFM.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Be sure to repeat the process for your field on the sub-total and grand-total rows.<\/p>\n\n\n\n<p>Click the &#8220;Save&#8221; button &amp; run your application. My output now looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/dataRoundingAfter.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/dataRoundingAfter.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">The Original Field was left unaltered to show the comparison between itself and the HTML edited field.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other Formatting Options<\/h2>\n\n\n\n<p>You can utilize numerous formatting, such as the following. (Assuming the field value is 1.234)<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Freemarker<\/th><th class=\"has-text-align-center\" data-align=\"center\"><strong>Output<\/strong><\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">${FIELD_o?string(&#8220;0&#8221;)}<\/td><td class=\"has-text-align-center\" data-align=\"center\">1<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">${FIELD_o?string(&#8220;0.#&#8221;)}<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.2<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">${FIELD_o?string(&#8220;0.##&#8221;)}<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.23<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">${FIELD_o?string(&#8220;0.###&#8221;)}<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.234<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">${FIELD_o?string(&#8220;0.####&#8221;)}<\/td><td class=\"has-text-align-center\" data-align=\"center\">1.234<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>You can even use this same method for Rounding purposes:<\/p>\n\n\n\n<p>\u00b7 If value = 1.2, then <code>${FIELD.string(\"0\")}<\/code> yields 1.<\/p>\n\n\n\n<p>\u00b7 If value = 1.8, then <code>${FIELD.string(\"0\")}<\/code> yields 2.<\/p>\n\n\n\n<p>\u00b7 If value = 1.5, then <code>${FIELD.string(\"0\")}<\/code> yields 2 (Rounding always goes to nearest even number).<\/p>\n\n\n\n<p>\u00b7 If value = 2.5, then <code>${FIELD.string(\"0\")}<\/code> yields 2 (Rounding always goes to nearest even number).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This documentation describes how to use Freemarker edit codes to hide decimals from view, while still allowing it to be used in calculating sub and grand total levels. Example Scenario So that you can easily see the difference, a Regular Report application has been built with the dimension key set&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[265],"ht-kb-tag":[],"class_list":["post-1399","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-freemarker"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=1399"}],"version-history":[{"count":12,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1399\/revisions"}],"predecessor-version":[{"id":13189,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1399\/revisions\/13189"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=1399"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=1399"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=1399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}