joeycn Posted December 19, 2006 Share Posted December 19, 2006 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 1b 5 Detail Bandc 3------------------------------------Sum:9 Group Footer------------------------------------ How can i get the sum number?Any suggestion will be appreciated! Link to comment Share on other sites More sharing options...
lucianc Posted December 19, 2006 Share Posted December 19, 2006 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 likeCode:<variable name="f2GroupSum" type=".." calculation="Sum" resetType="Group" resetGroup=".."> <variableExpression>$F{F2}</variableExpression></variable> HTH,Lucian Link to comment Share on other sites More sharing options...
mortoza Posted December 20, 2006 Share Posted December 20, 2006 Hi LuciancI am also trying to get a variable which is updated as cumulatively. Can you give me tips how do implement using iReport? Thanks in advance.Mortoza Link to comment Share on other sites More sharing options...
lucianc Posted January 3, 2007 Share Posted January 3, 2007 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 Link to comment Share on other sites More sharing options...
ujbi Posted January 4, 2007 Share Posted January 4, 2007 Hello, I run into the same problem. My details band consists of3 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 Link to comment Share on other sites More sharing options...
ujbi Posted January 4, 2007 Share Posted January 4, 2007 textfield evaluation time Auto fixes the problem. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now