Error Evaluating Decimal Value

I'm trying to conditionally format a value on my report if it is negative but I am not able to evaluate if a value is less than Zero or not.

I'm still new to Jaspersoft. Here is my custom formatting method.

<style name="NegativeAverage">
    <conditionalStyle>
        <conditionExpression>
            <![CDATA[new Boolean($F{AVERAGE_BALANCE} < 0.00 ? Boolean.TRUE : Boolean.False]]>
        </conditionExpression>
        <style isBold="true"/>
    </conditionalStyle>
</style>

Errors:

Errors were encountered when compiling report expressions class file:
 1. Syntax error, insert ")" to complete Expression value = new Boolean(((java.math.BigDecimal)field_AVERAGE_BALANCE.getValue()) < 0.00 ? Boolean.TRUE : Boolean.False; //$JR_EXPR_ID=14$ <--->
 2. Syntax error, insert ")" to complete Expression value = new Boolean(((java.math.BigDecimal)field_AVERAGE_BALANCE.getOldValue()) < 0.00 ? Boolean.TRUE : Boolean.False; //$JR_EXPR_ID=14$ <--->
 3. Syntax error, insert ")" to complete Expression value = new Boolean(((java.math.BigDecimal)field_AVERAGE_BALANCE.getValue()) < 0.00 ? Boolean.TRUE : Boolean.False; //$JR_EXPR_ID=14$ <---> 3 errors

Any help is greatly appreciated.

brian.berrelez's picture
Joined: May 9 2017 - 7:31am
Last seen: 5 years 7 months ago

1 Answer:

<conditionalStyle>
    <conditionExpression>
        <![CDATA[new Boolean($F{AVERAGE_BALANCE}.compareTo(BigDecimal.ZERO) < 0 ? Boolean.TRUE : Boolean.FALSE)]]>
    </conditionExpression>
    <style forecolor="#FF0000"/>
</conditionalStyle>
brian.berrelez's picture
Joined: May 9 2017 - 7:31am
Last seen: 5 years 7 months ago
Feedback