When a counter is created that uses the previous value of a variable, that its result is not correct because the expression of this variable is executed twice.
Two counters have been created.
- myCounter1 uses the previous value of the variable to incrementally compute the sum and resetType None
- myCounter2 uses the SUM calculation method and a resetType Report
The first counter is incorrect.
The second counter is correct.
Note that when the resetType of myCounter1 is set to Report than the calculation is correct.
If you debug the code, you'll notice that the expression of a variable is computed multiple times causing myCounter1 to be incremented twice for each record.
An example report has been created with a csv data set, an adaptor and a simple jrxml report.
Archief.zip
When a counter is created that uses the previous value of a variable, that its result is not correct because the expression of this variable is executed twice.
Two counters have been created.
The first counter is incorrect.
The second counter is correct.
Note that when the resetType of myCounter1 is set to Report than the calculation is correct.
If you debug the code, you'll notice that the expression of a variable is computed multiple times causing myCounter1 to be incremented twice for each record.
An example report has been created with a csv data set, an adaptor and a simple jrxml report.
Archief.zip