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

How to set a pattern of a BigDecimal variable as negative whenever applicable


anaghaphadke

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

I got this to work fine with the jrxml below (pattern was "###0.00;-###0.00").  This printed the negative value in question as:

-9423.00

If you wanted to include a comma separator and not include the zeroes after the decimal, you could instead use the pattern "#,##0;-#,##0", which prints the value as

-9423.00

Hope that helps!

Carl

 

Code:
<textField pattern="###0.00;-###0.00">  <reportElement style="BandedTable" mode="Opaque" x="0" y="0" width="100" height="20"/>  <textElement textAlignment="Right"/>  <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{RANDNUM}]]>      </textFieldExpression></textField>
Link to comment
Share on other sites

I'm starting to doubt that it's a problem with the pattern.  Is that last column a field returned from your query or a calculated value within iReport?  if it's a field that's returned from the query, have you used another tool to look at the raw data being returned by that same query to verify that those amounts are returned as negative?  On the other hand, if that column is a calculated value (or a variable, which is also a calculated value--just one that happens to have a name for easy reuse), I'd be interested in seeing what the value expression is that defines it.  My theory is that your "refund" amounts are still coming in as positive values and that you're going to have to either change your query or change the expression in iReport based on some other information.

If you copy your JRXML and paste it into the "Code:" box, I can try to take a quick look.

Carl

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...