Jump to content
Changes to the Jaspersoft community edition download ×

SUM incorrect - not adding last Subreport value


nealhudson

Recommended Posts

Hi

 

I'm pulling my hair out with this one. I have a Master report and Subreport. The subreport contains a few detail lines, and a subtotal. The subtotal is being displayed correctly. This is passed back to the Master report as a variable. I have another variable set up to total this, which is then displayed in the Summary section.

However - the value of the total displayed in the Summary section, is always short the final subtotal.

 

I've tried searching the forum but have been unable to find a resolution to this.

 

Mentioned in this post: http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func=view&catid=8&id=20508#20508

 

was that it mattered what order you defined the variables.

If I define the total first, then the variable which contains the subtotal returned from the subreport - I get the scenario listed above. If I reverse the order and define the subtotal variable, then the total - the total displays null.

 

I'm more than a little confused by this behaviour... - is this working as expected?

How do I return a subtotal from a subreport, and print an overall total at the bottom of the master report???

Link to comment
Share on other sites

  • Replies 12
  • Created
  • Last Reply

Top Posters In This Topic

mfassbender wrote:

Please check if evaluation time for the total field is set to "REPORT". Only in this case all subreports are evaluated before.

The total field is Variable, with Reset Type = Report. I don't see any evaluation time for the Variable.

 

For the text field that displays the total variable, I've tried Evaluation Time - Report, Now, Auto - all do the same thing - which is show the total not taking into account the last value returned from the subreport.

Link to comment
Share on other sites

svenn wrote:

I could never get this to work properly. I end up creating a separate class and using getter and setter to accumulate my totals.

Surely this is one of the most basic tasks of report writing - a Subtotal followed by a Total.

 

Frankly I'd be AMAZED if Jasper/iReports couldn't handle this kind of functionality without having to write it out separately in a scriptlet.

 

At this stage though there is no sight of a resolution, I'm unable to get any technical support on this, so may have to consider this convoluted approach to get around iReports/Jasper's shortcomings.....

Link to comment
Share on other sites

  • 3 weeks later...

I received a mail this morning from somebody having the same problem, so I thought I'd resurrect this thread and provide the example arianhojat was looking for.

 

I've attached a .zip file, containing a very basic subreport/report combination, and the 2 sql scripts needed to create the tables that the reports are based on.

 

To recreate a simple example of the problem, enter the 1st October as the from and to date for the report.

 

Thanks [file name=sample-2019c9c9ea8200d655f492229924651e.zip size=21749]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/sample-2019c9c9ea8200d655f492229924651e.zip[/file]

Link to comment
Share on other sites

Hi.

 

My problem was very similar as yours. I had some return values from a subreport wich I summarized in my master. The last value from the subreport didn`t appear in the total in my master, even tough the value missing in my sum is visible in my master. This is what I did to save my day:

 

Where you define the bindings between master variable and return variable from the subreport, you can set calculation type to sum. (Fig. 8-20 in Toffoli`s Ireport guide from sept. 2007)

Based on this you can summarize over the entire report or groups etc. depending on the master report variables reset type.

 

This solved my problem, I guess this could be helpful for others also.

Link to comment
Share on other sites

Ok I finally have seemed to be able to get the subtotals/totals to work now - thanks to the help from skalle!

 

However, I'm now having a problem working with those in the footer bands. I have created a report where I the subtotal is returned in minutes, and the correct value is available in the band (in the example it's displayed on the left). I have set up another couple of variable - 1 to give the time in minutes as hours, and the other to give it in minutes past the hour. So for example 187 minutes will be 3 hours, 7 minutes.

 

In the example that I have attached, in the first project footer the value in minutes is 120. However my variables display the value as null.

 

(to get a clear example, select 1st October 2007 as from and to dates)

 

Could someone please explain how to work with the subtotal value in a band?

 

Thanks [file name=calc_problem.zip size=22520]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/calc_problem.zip[/file]

Post edited by: nealhudson, at: 2007/10/16 12:53

Link to comment
Share on other sites

  • 4 years later...
  • 1 year later...

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