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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtotaling variables - NOT Possible ?

Status
Not open for further replies.

mirogak

Programmer
Sep 28, 2006
65
US
Hi folks,

Using Crystal Reports 11.5

I needed to pull data from different data sources - one is the Enterprise repository and the other is a local Oracle database.

The purpose of the report I am trying to create is pretty simple - Product category sales by province/state and compared to budget.

I pull Sales information in the MAIN report from the Enterprise repository and it looks like this:

Product_Type State Sales

Then I pull Budget information in a SUB-REPORT from the local database and looks like:
Product_Type State Budget

I link the sub-report by Product_Type and State and pass the Budget to the main report via a SHARED VARIABLE. And it ends up looking like this:

PRODUCT_TYPE STATE SALES BUDGET

Now I need to group them by Product_Type and State and show subtotals on Sales and Budget.

I can do everything except for showing sub-totals on the Budget because it is a shared variable. CR won't allow me to do subtotaling on variables.

Is there a work around? I will appreciate the help.

Thanks,
Mirogak
 
Yes. You can do this with a simple series of formulas to accumumate a GLOBAL variable. it's called the 3 formula technique and we've covered this in previous issues of our newsletter.

Editor and Publisher of Crystal Clear
 
Specifically, you can create formulas like these:

//{@reset} for the group header (if you want the total at the group level):
whileprintingrecords;
numbervar sumx;
if not inrepeatedgroupheader then
x := 0;

//{@accum} to be placed in the section containing the referenced shared variable (below the section containing the sub);
whileprintingrecords;
shared numbervar x;//where x = your shared variable name
numbervar sumx := sumx + x;

//{@display} to be placed in the group footer (if a subtotal) or report footer, if a grand total:
whileprintingrecords;
numbervar sumx;

-LB
 
Thank you Bass and chelsea ... this worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top