Jump to content
We've recently updated our Privacy Statement, available here ×

replace null value with a "-"/dash


vk01

Recommended Posts

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

One of the properties on a text field is "Blank when null". If you check it off your field will be blank and not contain "null".

 

It might be a better option than replacement logic. If you're set on a dash you could use a conditional expression in the field.

 

( <condition> ? exp1 : exp2 )

 

($F{yourValue} != null ? $F{yourValue}, "-")

Link to comment
Share on other sites

  • 4 months later...

Hi, I'm also trying to replace null.

 

This is what I have as Text field expression:

($V{SUM_RECEIPT_AMOUNT_STAT_CURRENCY_1} != null ? $V{SUM_RECEIPT_AMOUNT_STAT_CURRENCY_1}, "-")

 

It gives an error:

Parse error at line 1,column 89. Encountered: ,

 

What do I do wrong?

Link to comment
Share on other sites

Put ":" instead of "," in your expression, and then check the field type. This will work for string, for some other type you have to put that type instead of "-", or leave the field as String and setting the expression as ($V{SUM_RECEIPT_AMOUNT_STAT_CURRENCY_1} != null ? $V{SUM_RECEIPT_AMOUNT_STAT_CURRENCY_1}.toString() : "-")
Link to comment
Share on other sites

  • 13 years later...
($F{value1}!=null?$F{value1}:0)

jrxml variable declaration example

<variable name="varWithTernary" class="java.lang.Double" calculation="Sum">    <variableExpression><![CDATA[($F{value1}!=null?$F{value1}:0)-($F{value2}!=null?$F{value2}:0)]]></variableExpression></variable>

 

https://stackoverflow.com/questions/37674266/how-do-i-replace-a-null-value-with-0/37675092#37675092

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...