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

creating a list based on calculated values from the Detail


law

Recommended Posts

Hi all, I wonder if its possible to do the following with the records comming from a sql query:

say I have a report that has numerical values:

count 1:   300

count 2:    289

count 3:    256

count 4:   220

Is it possible to create a variable, an numeric Array that would contain the difference between the numbers? - like that:

Integer[] arr = new Integer[  300-289,  289-256, 256-220]

I can imagine this is a variable with execution time "Now", but can it be an array? and if so, how would I set up such a variable?

Big thanks in advance!

 

 

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi cmatthews,

In the dropdown for "Variable Class" I see options  java.lang.Integer,  java.lang.String, java.util.List. I have the newest iReport version installed. Where would I set java.lang.Integer to be java.lang.Integer[]?

When I had a variable declared as  java.util.List ls, then setting var Expression to ls.add($F{myNumField}), I'd get an error on attempt to "Preview" the report - ls.add function was not allowed. It seems like a simple thing, but...

Link to comment
Share on other sites

Ok, thank you, I was able to set it to be an array.
Now when I have it set in Variable Expression to this:
$V{ls}.add( $F{myfield} )
I get no errors, but ls is a null when tested in the page summery. I tested Calculation set to Nothing and System, but the array is empty. I even dragged it into the page Detail, still a null.



Post Edited by liw at 08/10/2012 21:21
Link to comment
Share on other sites

I changed Variable Expression from $V{ls}.add( $F{myfield} )

to $F{myfield}

 

So now, the array gets populated, but only with one value out many in the column. Does anybody have an idea how I could populate my array with every value of a specific field?

 

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