Formatting of values

Top  Previous  Next

A feature of aggregate functions is that the returned numerical values are not formatted, as shown by the first example, which uses “SUM”:

 

_img141

 

Data fields usually return a formatted value, which is simply displayed by the “Text” object without any change. To apply formatting to the “SUM” result, let's use the value formatting tools in FastReport.

 

Select the object containing the Sum and open the format editor either from 'Display Format...' in its context menu or through the “DisplayFormat” property in the object inspector.

 

clip0181

 

This editor lists the format categories on the left, the corresponding formats on the right and the format string and decimal separator for the selected category and format below. We’ll select the “Number” category and "$1,234.50" format. The format string is an argument for the Delphi "Format" function, which FastReport uses to implement number formatting. The format string and decimal separator can be changed. If the decimal separator is left blank then the current regional setup value is used.

 

After clicking ОК and previewing the report you will see that the Sum in the report is now formatted correctly:

 

_img143