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

Calculating a value in the SUBTOTAL

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I have a report which requires SUBTOTALS.

The problem starts with the third column which is calculated based off of the 1st and 2nd SUBTOTALS.

Example:

SUBTOTAL_A SUBTOTAL_B CALCULATED_VALUE
55 75 26.66%


Formula is:
((SUBTOTAL_B - SUBTOTAL_A)/SUBTOTAL_B) * 100


Can this be done in the Subtotal area?


Thanks,

Leo ;-)
 
DEFINE FILE CAR
SUBA/I6 = 55;
SUBB/I6 = 75;
END

TABLE FILE CAR
PRINT SUBA
SUBB
COMPUTE PCT/D6.2 = ((SUBB - SUBA)/SUBB) * 100;
BY COUNTRY
ON COUNTRY RECOMPUTE
ON COUNTRY SUB-TOTAL
IF RECORDLIMIT EQ 5
END

Returns

PAGE 1

COUNTRY SUBA SUBB PCT

ENGLAND 55 75 26.67
*TOTAL ENGLAND 55 75 26.67
FRANCE 55 75 26.67
*TOTAL FRANCE 55 75 26.67
ITALY 55 75 26.67
*TOTAL ITALY 55 75 26.67
JAPAN 55 75 26.67
*TOTAL JAPAN 55 75 26.67
W GERMANY 55 75 26.67
*TOTAL W GERMANY 55 75 26.67
*TOTAL W GERMANY 55 75 26.67
TOTAL 275 375 26.67

Is that what you were looking to do?
 
It appears like what i am trying to do, but I will have many detail records before the subtotals.

I'll try it and let you know.
Thanks.


Thanks,

Leo ;-)
 
In other words, the PCT field should be calculated from the SUBTOTALS; not the detail records.


Thanks,

Leo ;-)
 
The above code calculated the values for each row, but it's showing the total of the PCT column instead of showing the computed field as the PCT subtotal.


Thanks,

Leo ;-)
 
On the SUBTOTAL line ('ON field ...') do you say SUBTOTAL or SUB-TOTAL, which adds up the COMPUTEd field, or RECOMPUTE/SUMMARIZE, which redoes the calculation, based on subtotaled values?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top