Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store Group Summaries in variables

Status
Not open for further replies.

mirogak

Programmer
Sep 28, 2006
65
US
Dear Folks,

I am using Oracle 8i and CR XI R2 (11.5)

I have a simple summary report which gives me a summary view of YTD and LastYearYTD Sales.

Range of data that I am pulling: {SALE.INVOICE_DATE} IN YTD OR {SALES.INVOICE_DATE} IN LastYearYTD

I then group by the year field {SALES.YEAR}, and take the summary on the field {SALES.GROSS}. I get an output similar to:

YTD 2007
GROSS
--------
$450,500

YTD 2006
GROSS
--------
$330,050

What I want to do is to store the two different totals in two shared variables so that I can pass them along to another report.

I tried a bunch of things in the Formula Editor and Running Totals but to no avail.

Any suggestions?

I tried something like this:

if (GroupName ({SALES.YEAR})= totext(Year(currentDate))) then
Sum ({SALES.GROSS}, {SALES.YEAR})

to get the 2007 total but it simply gave me 0.

cheers,
mirogak
 
Pass to another report, as in this is a main report and you have a subreport or vice versa?

You need shared variables, as in:

whileprintingrecords;
shared numbervar thisyear;
shared numbervar lastyear;
if year({sales.year}) = totext(year(currentdate),0,"") then
thisyear:=thisyear + {sales.gross};
if year({sales.year}) = totext(year(currentdate)-1,0,"") then
lastyear:=lastyear + {sales.gross};

Place the formula in the details section.

Now after this report has run, the values are available as in:

whileprintingrecords;
shared numbervar thisyear;
thisyear

for last year:

whileprintingrecords;
shared numbervar lastyear;
lastyear

Which you can reference from subreports or back in a mainreport.

-k
 
Synapsevampire!

why does it matter if "this" report is a main report or another sub-report within a main report? I should be able to call the shared variable from either one. right?

Also, the solution you're suggesting above is similar to a running total with a condition on year. correct?

I am at home, thus can't test your solution right this moment. I will respond tomorrow morning.

Thanks for your input. Much appreciated.

Good night,
mirogak
 
Well because you use shared variables when passing between subreports and main reports, not between main reports.

Since you seemd to have notion of shared variables, I wanted to clarify that this is for passing between nested reports, not external reports.

-k
 
Well because you use shared variables when passing between subreports and main reports, not between main reports.

Since you seemed to have no notion of shared variables, I wanted to clarify that this is for passing between nested reports, not external reports.

-k
 

Ahh nice, it worked.

But why do say in your post above

"Now after this report has run, the values are available as in:

whileprintingrecords;
shared numbervar thisyear;
thisyear "


Why do I need the statement "whileprintingrecords" just before declaring the shared variable in the other sub-report.

And yes to your question, the report in which I created the shared variable and the report where I use it, are both sub-reports within a larger main report.

Thanks synapse!

cheers,
mirogak
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top