matt.mitchell Posted January 18, 2013 Share Posted January 18, 2013 I have a few column of integers taken from a database. In a subreport, I want to have a summary table of sorts with things such as average.I created a variable to calculate the average with the built in variable calculations, but this is calculating the average line by line.This was easily fixed by setting the evaluation time to report. It now calculates the total average but is printing it out for each line and I just want it printed once.I attempted to solve this by using a print when expression and this works to print the value once, but the subreport still generates blank pages for each line after the first print (the subreport is one row in size). So in a column with 15 integers, the average is calculated and printed, but there are 14 blank pages after it.How can I have things such as sum, average, lowest, highest, standard deviation, etc. calculate and print one number?UPDATE: Moving the value in the subreport to the summary band allows it to be shown once. But when this subreport is imported into the master report, it still repeats for each line in the detail band. I want the subreport in the detail band beside the data chart, see below. http://i.imgur.com/KHM2n.png Link to comment Share on other sites More sharing options...
lisacbeaton Posted January 18, 2013 Share Posted January 18, 2013 Matt - are you displaying the results of these calculations in your detail band? Try moving them to your Summary band. Link to comment Share on other sites More sharing options...
matt.mitchell Posted January 18, 2013 Author Share Posted January 18, 2013 I moved the variable in the subreport jrxml to the summary band. Previewing that gives me one value. Problem with this is that in the master report it still repeats the subreport. I've mocked up what is happening in here: http://i.imgur.com/KHM2n.png Link to comment Share on other sites More sharing options...
lisacbeaton Posted January 18, 2013 Share Posted January 18, 2013 Unfortunately, anything placed in your detail band will be repeated with every detail band output row, unless you use a "Print When" expression to limit the output to a certain row number. What if the left-side portion was actually a subreport, and you dropped that into an outer wrapper report. In the outer report, you could split the detail band into 2 columns and display the subreport with the data on the left. In that subreport, calculate your averages in the report footer but don't display them. Pass them back to the outer report as return values. You would be doing all of this with the goal of having only one row in the outer wrapper report's detail band. Maybe someone else will have a better solution. I have had to get creative sometimes to achieve the layouts I'm looking for. For example, if you know you're always going to have X number of rows in your data table (I do a lot of "this month, last month, and the month before that" in my reports), you could use something like Oracle's decode function (not sure what kind of database you're using) to get all of the data in one row, and then you can arrange your text fields as you please within the single output row. Link to comment Share on other sites More sharing options...
anaullah Posted January 22, 2013 Share Posted January 22, 2013 Option 1: Rather than using a new colum to show average for all columns, show average at bottom of each column by using summary. In below table i am doing some in summary section. Amount 23 45 20 Total 98 Option 2: You can control your report layout via java code. I mean whatever object you passing to the report add two more variable. While you are iterating your collection from database populate these additional columns with your catlculated value for first 3 rows to show 3 different values. 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