Hi all:
When I define a variable which will sum the fields in the detail band, I find that there is no increasement definition that starts with detail, it must be increased by group ????
I am not sure I've made myself understood. As a result, the following text is an example:
------------------------------------
F1 F2 Group Header
------------------------------------
a 1
b 5 Detail Band
c 3
------------------------------------
Sum:9 Group Footer
------------------------------------
How can i get the sum number?
Any suggestion will be appreciated!
When I define a variable which will sum the fields in the detail band, I find that there is no increasement definition that starts with detail, it must be increased by group ????
I am not sure I've made myself understood. As a result, the following text is an example:
------------------------------------
F1 F2 Group Header
------------------------------------
a 1
b 5 Detail Band
c 3
------------------------------------
Sum:9 Group Footer
------------------------------------
How can i get the sum number?
Any suggestion will be appreciated!
5 Answers:
Posted on December 19, 2006 at 9:46am
If you don't specify any increment type for the variable, it will increment at each row by default. Your confusing is probably caused by the fact that this default increment type is counter-intuitively called "None".
You can find many examples of group total variables in the JasperReports samples. You would need to do something like
You can find many examples of group total variables in the JasperReports samples. You would need to do something like
Code: |
<br /> <variable name="f2GroupSum" type=".." calculation="Sum" resetType="Group" resetGroup=".."><br /> <variableExpression>$F{F2}</variableExpression><br /> </variable><br /> </td></tr></tbody></table><br /> <br /> HTH,<br /> Lucian |
Posted on January 3, 2007 at 3:06pm
I'm not an iReport expert, but this is straightforward. Say you want to sum values of the myField field. You would:
add a variable named myFieldSum. having the same (numerical) type as myField, Sum as calculation type, Report as reset type, None as increment type and $F{myField} as variable expression.
place a text field on your summary band (or on the title band with evaluation="Report") that displays $V{myFieldSum}. [/ol]
HTH,
Lucian
HTH,
Lucian
Posted on January 4, 2007 at 8:49am
Hello,
I run into the same problem. My details band consists of
3 columns, col. 0 is the party name, col. displays the votes ( $F{votes} ) of the party and col 2 should display the percentage. To calculate the percentage you need to sum up all votes e.g. $V{totalVotes}
But what I got is not the percentage but a value like
$F/{votes} / (current value of $V{totalVotes}) * 100 [%].
When I display $V{totalVotes} in the summary band it looks ok.
So the details band looks like:
Party 1 1 100%
Party 2 2 66.666%
Party 3 3 50%
Party 4 4 40%
Summary band:
Total 10
So how can one achieve that the calculation of the variable is done *before* the details band is evaluated.
BTW: the same thing happens if I want to display $V{totalVotes} in a pie chart where the value expression is the votes field. This happens even If I put the chart into the summary band.
Gernot
I run into the same problem. My details band consists of
3 columns, col. 0 is the party name, col. displays the votes ( $F{votes} ) of the party and col 2 should display the percentage. To calculate the percentage you need to sum up all votes e.g. $V{totalVotes}
But what I got is not the percentage but a value like
$F/{votes} / (current value of $V{totalVotes}) * 100 [%].
When I display $V{totalVotes} in the summary band it looks ok.
So the details band looks like:
Party 1 1 100%
Party 2 2 66.666%
Party 3 3 50%
Party 4 4 40%
Summary band:
Total 10
So how can one achieve that the calculation of the variable is done *before* the details band is evaluated.
BTW: the same thing happens if I want to display $V{totalVotes} in a pie chart where the value expression is the votes field. This happens even If I put the chart into the summary band.
Gernot