Taking sub-total totals to grand totals

Richard Kreiss rkreiss at verizon.net
Tue Nov 1 15:27:54 PDT 2016



> -----Original Message-----
> From: Filepro-list [mailto:filepro-list-
> bounces+rkreiss=verizon.net at lists.celestial.com] On Behalf Of scooter6---
via
> Filepro-list
> Sent: Tuesday, November 1, 2016 5:10 PM
> To: filepro-list at lists.celestial.com
> Subject: Taking sub-total totals to grand totals
> 
> Probably a bad description and probably a simple solution that my very
tired
> brain can't do right now
> 
> I have a report that subtotals on client number and gives a summary of
number
> of records over a given input of 2 dates....
> 
> This is run from the file that has the records in it and looks up client
file,etc...
> 
> Client Number      Name                     Type                # records
>
----------------------------------------------------------------------------
---
> 01234                     ABC Co                   06
8
> 01235                     XYZ Co                   09
10
> 01236                     ZZZ Corp                06
> 4
> 
> These data lines are in the subtotal part of the report
> 
> When it looks up the client (ABC Co and XYZ Co) it also finds the Type....
> 
> In the Grand Total of my report, I want it to also breakdown total by
Type....
> 
> Total 06           12
> Total 09           10
> 
> How do I get it to capture the Grand Total of Type at the end of report?
> 
> Brain dead....
> 
> Scott
> PDM

You can set up arrays with enough elements to hold the number of types and
the type totals.

Dim ctype(10):ya;dim ctotal(10):za

At the sub-total.  Type could be the field number holding this value or the
field_name.  
	If: ct ne "1"
	Then: ct="1";
Loop 	If: ctype(ct) = ""
	Then: ctype(ct)=type
	If:  ct lt "10"
	Then: ct=ct+"1";GOTO loop
	If: 
	Then:  ctotal(type)=ctotal(type)+ at rs (or whatever the field value is
that holds this total)
	If:
	Then: END
On the grand total section have defined dummy fields print the type values
based on the array element location:
Aa="total"<ya&"    "&za
Ab="Total"<yb&"    "&zb
etc

There are other ways to approach this but you need to have global fields to
hold your totals.  An array is the easiest way to do this this.

It is a shame that an array can't be dimensioned on the fly.  If it could,
then once all the records have been selected, a process could be run using a
getnext to count the number of types for this report and then dim ctype(rc)
where rc is the total number of types.

Of course if there is a master file with the type number and description,
one could always fill ctype from there.  It still would be nice to be able
to count the records used in this file and then set then dim the array with
that value.  This would allow the array to be dynamic in size.  No change in
programming if more types are added or one or more are deleted.





More information about the Filepro-list mailing list