Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports: default value instead of 'null'

Is there any way to set a default value to a field in a report? I have a lot of String fields in a report and would like them to display "0,00" when they're null.

like image 992
leandro Avatar asked Mar 08 '10 15:03

leandro


People also ask

Is blank when null Jasper?

If the "Blank when null" is checked and its contains static text inside the text field the database fields ($F{}) will return null (if the field has no value). I could use a NVL(test,' '), but the space will be underlined.


2 Answers

Supposing the field name is "value", in the "Text Field Expression", write:

($F{value} != null) ? $F{value} : "0.00"

like image 159
medopal Avatar answered Oct 13 '22 04:10

medopal


You can also select "Blank when null" in the properties of the text field if you want that. Other options are more flexible but this does the trick very quick and easy.

like image 44
Christian Vielma Avatar answered Oct 13 '22 02:10

Christian Vielma