Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

acumulative sum with ireport

jhon masco
Ranch Hand
Posts: 98
Hi everybody
I need to do a sum acumulative in a column of my report. I retrieve a value from the database and I fill the other columns with some mathematical operation with this value.
The last column must be the sum and in every row it must to sum the above value also: For example;

How Can i do that? I dont find the way. I had tried some variablesand things similar to : \$V{var1}= \$V{var1}+\$V{TOC} and i get errors.!
I using Ireport 4.0.
Please let me know if that is possible in ireport?
Thanks

jhon masco
Ranch Hand
Posts: 98
I solved the problem!!! Thanks...

Nitesh Kant
Bartender
Posts: 1638
• 1
jhon masco wrote: I solved the problem!!! Thanks...

It will be great if you can also give us the solution.

jhon masco
Ranch Hand
Posts: 98
It will be great if you can also give us the solution

You are right sorry!

Note: my main language is not english and I dont live there, therefore i will try to write everything correctly
Here the solution:
create a variable for each operation or formula, is to say:
Variable1 = (2000/2) or (DATADB/2)
Variable2 = (2000 *60)/365 or ((DATADB*60)/365)
Variable3 = (Variable1 + Variable2)
Variable4 = (Variable3)

them in the Variable4 properties set:
Variable Class = java.lang.double
Calculation = Sum
Reset Type = Column or Page or Report (depend you case)
Increment type = Group
Increment Group = (choose the group that you created before, when you use the wizard for example you create a group)
Variable Expression = (\$P{Variable3}>0) ? \$P{Variable3}: 0

And ready, that is all.
Any doubt let me know
Suerte