Is it possible to use space as separator formatting thousands for number in Data element?

Options
betasharko
edited February 11, 2022 in Analytics #1

Hello!
I need to separate thousands for numbers in Data element of BIRT report. But customer wants to use spaces as separators. Is it possible?
For example, to display a string I can use Java code to format it. Like next:

var locale = java.util.Locale.FRENCH;
var formatSymbols = new java.text.DecimalFormatSymbols(locale);
formatSymbols.setDecimalSeparator(',');
formatSymbols.setGroupingSeparator(' ');
var decimalFormat = new java.text.DecimalFormat("###,###,##0.00");
decimalFormat.setRoundingMode(java.math.RoundingMode.HALF_UP);
var result = decimalFormat.format(curValue);

But I don't understand how it can be applied in Data element.
Thank you for any help!

Answers

  • jfranken
    edited April 17, 2018 #2
    Options

    I tried but was unable to create a number format containing a space. One alternative is to change the data type to a string and use JavaScript to manipulate the string. Here is an example:

    Double click the column ('Amount' in this example) to edit the data binding. Change the data type to String and click the fx button to edit the expression. The expression that is shown on the right is just an example. It adds a space after the second character from the left in the string. You will need to modify the code to achieve your desired formatting and test it with your data. The code is standard JavaScript except that BIRT provides dataSetRow["your_column"] to insert the value for the current row into the expression. The table iterates through all of the rows.
    Because the column was changed to a string, if you want to add an aggregation, i.e. grand total, you will need to create a computed column containing the original column value that is numeric and add it to the table. You can turn off the visibility. Base the aggregation on the sum of the values in the hidden computed column.

    Warning No formatter is installed for the format ipb