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

Subtotal on top-n

Status
Not open for further replies.

JeroenBoon

Technical User
Aug 15, 2002
106
NL
Hello,

I have a report in which I group on costumer. For each costumer all the sales amounts are grouped and the footer is displayed. I use the top-N-expert to sort the costumers descending based on the grouptotals.
With a parameterfield I retrieve a number that I use to print the report conditional: only the groups with groupnumber<={?parameterfield} are displayed.
Now I want to make a subtotal for the displayed costumers. I use the next formule:

whileprintingrecords;
numbervar subtotal;
if groupNumber<=({?parameterfield}) then subtotal:=subtotal+Sum ({@amount}, {@costumer})

In each groupfooter I can place this numbervar and it works correctly, but I want to print the subtotal of the last displayed groupfooter somewhere else in the report.

Is there a way to do this?

Thanks,
Jeroen Boon.
 
Can you give an example of what you mean by illustrating some data?
 
Naith,

I will try:
Say I want to display the groupfooters of the top 4 costumers and suppress the rest of the footers:

groupnr 1:costumer A € 100 (subtotal 100)
groupnr 2:costumer B € 95 (subtotal 195)
groupnr 3:costumer C € 80 (subtotal 275)
groupnr 4:costumer D € 60 (subtotal 335)
(groupnr>4 is suppressed)

grandtotal € 1000
I now want to print somewhere in the reportfooter: &quot;subtotal of the top 4: € 335&quot;

Any more clear?

Jeroen Boon
 
WhilePrintingRecords;
NumberVar TopNSummary;

If groupNumber <= ({?parameterfield})
Then TopNSummary := TopNSummary + {@amount}
Else TopNSummary;

in the details section.

WhilePrintingRecords;
NumberVar TopNSummary;

in the report footer.

Is this what you mean?

Naith
 
Thanks Naith,

the simple:&quot;WhilePrintingRecords;
NumberVar TopNSummary;&quot; did the trick!

Sometimes I feel such a beginner...

Jeroen Boon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top