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

How to count a Running Total ?

Status
Not open for further replies.

omargpe

IS-IT--Management
Feb 5, 2003
22
US
Hi I will explain my problem with an example, I hope you can understand me.
let's say that i have a table with 3 columns "ProductName", "Date" and "Sales". and i want to separate them first by "Date" and then by "ProductName",
and also i've done a running total "MaxofSales" that takes the max of the sales of each product and then I want a sum of the "MaxOfSales" including all the products, and at the end of the report i want a grand total of the sales and also to show the max of the sum "MaxInDates"
Date - ProductName - Sales - MaxofSales - Sum - MaxInDates
01/01/06
HD
HD 1
HD 8
HD 3
HD 8
DVD
DVD 5
DVD 2
DVD 9
DVD 9
CD
CD 2
CD 1
CD 3
CD 3
01/01/06 20
02/01/06
HD
HD 5
HD 4
HD 7
HD 7
DVD
DVD 1
DVD 2
DVD 6
DVD 6
CD
CD 8
CD 4
CD 6
CD 8
02/01/06 21
03/01/06
HD
HD 2
HD 9
HD 1
HD 9
DVD
DVD 5
DVD 3
DVD 4
DVD 5
CD
CD 2
CD 1
CD 4
CD 4
03/01/06 18
Grand Total= 77 21


I hope some one could understand me with this example. This report is almost finished just left the "Sum" and the "MaxInDates".
I've tried with another Running Total but it's unable when i look for the first running total.
If someone knows how to make a running total with another running total please tell me...

TNXS

Salu2
()|\/|@®
 
You can't use Running Totals in Running Totals, you need to create your own.

Most successful posts include less data, and provide:

Crystal version
Database/connectivity used
Example data (this means the database, not how you're displaying it in Crystal)
Expected output

If you've grouped the data by the data points of interest, then you can create conventional formulas, such as:

maximum({table.value},{table.grouplevelfield})

If you want the max of all of them, use:

maximum({table.value})

To get the maximum of some value in an inner group level, use the 3 formula method:

outer group header formula:
whileprintingrecords;
Numbervar MyMax:=0;

Group level where you are finding the max:
whileprintingrecords;
Numbervar MyMax;
if maximum({table.value},{table.groupfield}) > MyMax then
MyMax:=maximum({table.value},{table.groupfield})

Outer group footer (display here)
whileprintingrecords;
Numbervar MyMax

Hopefully this gets you close.

I tend to avoid Running Totals, but somethimes they make sense when you don't need the sorts of things you do.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top