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

Summation and printing in arrays

Status
Not open for further replies.

UHsoccer

Programmer
Apr 24, 2003
139
0
0
US
I need to create subtotals for sales persons based on business categories. For each person I need to print the results.
Here is what I have sofar

1) --------- Formula to initialize arrays
whileprintingrecords ;
shared stringvar array catDes := MakeArray("Hardware","Software","");
shared numbervar array catVal := MakeArray(0,0,0);
shared numbervar numCat := 3;


2) ----- Formula to increment the amount
// numCat is the number of business categories
// catDes = Business category description
// catval = the accumulated amount for each category
whileprintingrecords ; shared numbervar numCat ;
shared stringvar array catDes ;
shared numbervar array catVal ;
numbervar num;
// Accumulate amount for each category
for num := 1 to numCat do
if {Sales.Code} = catDes[num] then catVal[num] := catVal[num] + {Sales.Amount})
else // to handle "undefined" or blank categories
catVal[num] := catVal[num] + {Sales.Amount})

3) ---------- Formula to print all amounts and provide a header
??? How do I print the array results in a footer section from 1 to numCat
 
You can simply group by Sales Person (at level 1) and within that by Category (level 2).

You can then simply show the information without any need for variables and complex formulas.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thanks for the reply, I got the grouping for each person

The content changes for each salesperson, that is of the 30 some categories each person may have from 2 to 10 and they are usually not the same.
Is there a way to display the totals for each category in the footer section
 
Just group by Category within person.

Perhaps I don't understand the question. Please clarify what the output should look like.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Here is a simplified ouput

Person-1 XXX
cat-1 $1000
cat-3 $2000

Person-2 YYY
cat-2 $2500
cat-3 $5000

Footer summary

Category Totals
cat-1 $1000
cat-2 $4500
cat-3 $7000

It is the footer summary that I need to display
 
For the Footer Summary, simply insert a CrossTab in the Report Footer.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Ido,

Thank you for the reference to Cross-Tables (CT). Never used them, now I have.

However, I have two questions:

1) How can I use a single CT where the rows are my categories and the Column fields are to be Cost, Price and margin? So what would be in the summarized field? I kind off faked it by creating three of them side by side. But that is not very professional looking

2) When I use three CTs (Cost, Price and Margin )with Column being the sales person, it does not display data in one of them.
Say the blank one is Cost. When I then remove Price CT, the Cost CT now shows data!
Quite predictable, but do not understand why
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top