0

I am desperately trying to format the Field "FilmID" based on it's value. Could you provide me with a conditional expression to format values >= 3 in red color ?

Conditional Style

Thanks a lot in advance!

Another variant of this question would be, what did I do wrong in this expression:

<style name="Style1" mode="Opaque" backcolor="#DBD82A">
        <conditionalStyle>
            <conditionExpression><![CDATA[$F{Revenue} > 10000]]></conditionExpression>
            <style mode="Opaque" backcolor="#C92B28"/>
        </conditionalStyle>
    </style>
Kurt Koala
  • 19
  • 5
  • Possible duplicate of [Change text field data color (Foreground color) based on condition in JasperReports](http://stackoverflow.com/questions/8754448/change-text-field-data-color-foreground-color-based-on-condition-in-jasperrepo) – Alex K Jul 18 '16 at 19:42

1 Answers1

0

Assuming that $F{Revenue} is numeric (Integer, Double, Float ecc)

if you are using jasper report version 6.0 or above there is nothing wrong with your style expression, for jasper report 3.0, you need new Boolean($F{Revenue} > 10000)in expression.

You need also to be sure that you apply the style to a report element.

<reportElement style="style1" x="49" y="4" width="100" height="20" uuid="865e11e4-c2d4-40ac-be06-dc1359dc93c0"/>
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
  • It is strange, later that day I tried the exact same thing as before and it worked both for string and numerical values. – Kurt Koala Nov 08 '15 at 19:15
  • That it worked with $F{Revenue} as String is really strange!, jasper report should exit with error "The operator < is undefined for the argument type(s) String, int" – Petter Friberg Nov 09 '15 at 08:17
  • Maybe it matters if report language is set to groovy or Java ? Also only != works with string, while == doesn't. However equals does. – Kurt Koala Nov 09 '15 at 08:32
  • If you use groovy == is compareTo (should work), it will compile and it will compare your String to your int..., , however < or > will not work in groovy. – Petter Friberg Nov 09 '15 at 08:46