Jump to content
Changes to the Jaspersoft community edition download ×

Need help with parameter / formula


Recommended Posts

I am a newbie to iReport and need help creating a parameter / formula field.


I have a data base column called "eq_res". I need a formula that would do something like this...


if {eq_res} = "D" then Daily




if {eq_res) = "M" then Monthly




if {eq_res) ="H" then Hourly




no reservation



basicly I need the report to display the word "Monthly" if eq_res = M or display "Daily" if eq_res = D etc.....


Can anyone help with this?????

Post edited by: dansky, at: 2007/03/16 19:07

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

You can do this in the either source query or in the expression.



To do it in the data source you use functions available in the database. This is an ORACLE example:


SELECT field1

, field2

, DECODE(eq_res,'D','Daily','M','Monthly','H",'Hourly','') AS eq_res

FROM yourTable



Then your expression would simply be $F{eq_res}




This is what you would do if you want to manipulate $F{eq_res}within an expression:



new java.lang.String($F{eq_res}=="D" ? "Daily" : ($F{eq_res}=="M" ? "Monthly" : ($F{eq_res}=="H" ? "Hourly" : "") ) )

Post edited by: jmurray, at: 2007/03/17 02:37

Link to comment
Share on other sites



I have a simmular problem.

In my case I have a database field (integer) lineitemtype. When it is 0 I want to return a string "Artikelen" when it's 1 I want to return a string "Uren" and when it's 2 I want to return a string "Kosten"


I have this expression:

new java.lang.String($F{lineitemtype} == new Integer(0) ? "Artikelen" : ($F{lineitemtype} == new Integer(1) ? "Uren" : ($F{lineitemtype} == new Integer(2) ? "Kosten" : "other"«») ) )


but the problem is that what the value is it is always returning the string "other" And I'm sure the integer is 0 or 1 or 2, nothing else.


What am I doing wrong??

Post edited by: HJK, at: 2007/03/23 09:31

Link to comment
Share on other sites

  • 11 months later...

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