Author |
Message |
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Topic: Running total from subreport in main report Posted: 10 May 2010 at 2:11am |
I have created a sub report which contains a total of three codes on a monthly basis, I now within the main report need to have a grand total of all the months totals. is this possible
Month Subreport total KWH Total
201002 1,791.38 19920
201001 1731.20 19240
201003 1706.43 18960
201004 1143.63 12600
6372.64 70720
The total of 6372.64 is the total I am trying to create from the sub report.
Carmon
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
 Posted: 10 May 2010 at 3:35am |
use a shared variable, one per item you want to return to the main report.
Set the shared variable in the subreport, then access it in the main report. You would probably want to store it in another variable, or if you never reset it, just keep having your subreport update the shared variable and report on it at the end of the report.
HTH
|
IP Logged |
|
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Posted: 10 May 2010 at 9:10am |
I have placed my shared variable in the subreport and declared it in my main report. I placed my declared formula under the section containing my subreport the totals are correct but I still can not figure how to get my sum of that set of numbers. Thanks for the information so far!
Edited by clumbsy - 10 May 2010 at 9:35am
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
 Posted: 11 May 2010 at 3:12am |
ok, in the main report...just to keep the example separate...create global variables, and as the shared variable values come back to the main report, increment the global variables. Something like:
shared numbervar subTotal;
global numbervar mainTotal := mainTotal + subTotal;
This will sum any value that you choose.
Notes: Global variable are only available to the report that they are written in (so scoped to only the main or only the subreport). Shared variables are allowed to cross the line between main and subreport. If creating your totals, remember that if you have grouping and you want the totals to reflect the values in a group or set of groups you will need to reset the variable to 0 at some point, and you might need to increment another variable to keep a higher group totals correct.
HTH
|
IP Logged |
|
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Posted: 04 Jun 2010 at 8:42am |
Sorry, took so long..everything went well so far now I have to add in an average column which take the subreport & column divided by the main report KWH column. I thought I had it but again the numbers are not resetting in my formula which is
@mainformula is my subreport and the other is main report.
~Carmon
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
 Posted: 07 Jun 2010 at 3:20am |
I would try separating the formula and making sure that each part is what you expect. This will allow you examine what is occurring...if the subreport is always reporting the value from the previous record, then you need to move where the subreport is called, if the total is too high or too low, you can investigate that as well.
it's always easier to figure out what is going wrong when you can see the pieces instead of the whole.
HTH
|
IP Logged |
|
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Posted: 07 Jun 2010 at 3:49am |
it looks like below
$ KWH Average
207.59 2022
|
IP Logged |
|
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Posted: 07 Jun 2010 at 3:59am |
It looks like this below
$ KWH Average
207.59 2022 -
167.33 1567 0.132
162.98 1469 0.114
212.63 2012 0.081
1st main repot average from
subreport subreport
column column $/KWH
formula is (@@@MainFormula)/(bi_Hist_Usage.Bi_Usage)
I just cant seem to get it to reset. I have the average placed in the group header section(date). It all calculates correctly just one row off.
Edited by clumbsy - 07 Jun 2010 at 4:15am
|
IP Logged |
|
clumbsy
Newbie
Joined: 24 Sep 2009
Location: United States
Online Status: Offline
Posts: 16
|
 Posted: 07 Jun 2010 at 4:34am |
I hope I solved it I just took my subreport amount, created a formula with subreport amount / 1 and placed that total in the row I needed it to be in .
|
IP Logged |
|
|