0

I am trying to append "%" to a textfield conditionally, but I am getting this error :

  1. The method IF(boolean, String, String) is undefined for the type

    SuiviExercice_1441008823562_230431 value = IF(((java.lang.String)field_libelle.getValue()).equals(""),String.valueOf(((java.lang.Double)field_octoberData.getValue()))+"%",String.valueOf(((java.lang.Double)field_octoberData.getValue()))); <>

Does anyone know why?

Alex K
  • 22,315
  • 19
  • 108
  • 236
user1260928
  • 3,269
  • 9
  • 59
  • 105
  • `IF` statement cannot have 3 parameters. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html – Mani Deep Sep 03 '15 at 12:59
  • Possible duplicate of [doing comparison if else in iReport](http://stackoverflow.com/questions/4437323/doing-comparison-if-else-in-ireport) – Alex K Mar 29 '16 at 07:40
  • ths same as https://stackoverflow.com/questions/42247300/jasper-report-if-condition-in-text-field-value – frank Nov 21 '19 at 03:12

1 Answers1

3

What about using ternary operations?

some_condition ? condition_was_true : condition_was_false

in your case:

your_condition ? your_text + "%" : your_text

dreamca4er
  • 381
  • 3
  • 14