Search code examples
jasper-reportsireportjasperserver

concatenate without losing thousands separator


I have a report that brings total sales and total probability sale. The request was that this be shown in one table as "R"{totalamount}" (R"{totprobamount")".

So i added this together in a variable with the variable expression being

"R" + $F{Totalt} +" (R" + $F{Totalp} +")"

but by doing this the Thousands separator does not show anymore?


Solution

    • If you can add a field for each value you wouldn't do this with String concatenation but by using patterns on text field. add for each field in the properties panel a patter such as R #,##0.00.

    • if it has to be in a single field you'd need to add an expression to actually format the numbers in the desired way such as for example: "R" + new DecimalFormat("#,##.00").format($F{Totalt}) + " (R" + new DecimalFormat("#,##.00").format($F{Totalp}) + ")"