Using HTML Edit Codes to Control Data Rounding

 

This documentation describes how to use HTML edit codes to hide a decimal field from view, while still allowing it to be used in calculating sub and grand total levels.

To begin with, be sure to use the Web 2.0 Report template when building your application.

So that you can easily see the difference, an application has been built, sequenced by State. Only one Numeric Field has been selected. For comparison purposes, a calculation has been used to replicate this numeric field.

Before any editing is done, my output looks like this:

Since this requires HTML editing, we must open m-Painter.

Right-click on your field at the detail level, and select "Cell" then "Edit Cell HTML". Replace ?html} with _o?string("$,##0")}.

Be sure to repeat the process for your field on the sub-total and grand-total rows.

Click the "Save" button & run your application. My output now looks like this:

Note: The Original Field was left unaltered to show the comparison between itself and the HTML edited field.

Note: You can utilize numerous formatting, such as (Assuming the Field value is 1.234):

· ${FIELD_o?string("0")} <– yields 1

· ${FIELD_o?string("0.#")} <– yields 1.2

· ${FIELD_o?string("0.##")} <– yields 1.23

· ${FIELD_o?string("0.###")} <– yields 1.234

· ${FIELD_o?string("0.####")} <– yields 1.234

You can even use this same method for Rounding purposes:

· If Field = 1.2, then ${FIELD.string("0")} yields 1.

· If Field = 1.8, then ${FIELD.string("0")} yields 2.

· If Field = 1.5, then ${FIELD.string("0")} yields 2 (Rounding always goes to nearest Even Number).

· If Field = 2.5, then ${FIELD.string("0")} yields 2 (Rounding always goes to nearest Even Number).

 

Created: February 29, 2008 | Modified: September 3, 2013