Focal Point
Using two Subtotals to calculate a ratio

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6381088331

August 10, 2005, 02:50 PM
Tim J
Using two Subtotals to calculate a ratio
I am getting a brain cramp trying to tackle this problem:

I have a report that has three subtotals based on three different part types:

Type 1 Part1 $111
Part2 $111
Part3 $111
Subtotal 1 $333
Type 2 Part1 $111
Part2 $111
Subtotal 2 $222
Type 3 Part1 $111
Subtotal 3 $111

I need to do a ratio calculation of Subtotal 2/Subtotal 1 as long as Subtotal 1 is greater than 0.

The user actually wants this ratio as part of the Subtotal 2 line which is another animal in itself.

Any ideas how I can tackle this problem or restructure my report to handle this?

Any help is appreciated!

Thanks,
Tim
August 10, 2005, 03:15 PM
susannah
ouch...a brain cramp...You probably want to look up the RECAP command and the ST. prefix. That ought to do it for you.
August 10, 2005, 03:24 PM
reFOCUSing
You can also do this using SUBFOOT.
Here is what I think your trying to do:
DEFINE FILE CAR<br />TYPE_NUM/A6 = DECODE COUNTRY('ENGLAND' 'TYPE 1' 'FRANCE' 'TYPE 2' 'ITALY' 'TYPE 3');<br />END<br />-RUN<br />-*<br />TABLE FILE CAR<br />SUM<br />RETAIL_COST<br />COMPUTE RATIO/D10.7S = 0;<br />COMPUTE ORD/A1 = '1';<br />BY TYPE_NUM<br />BY CAR<br />WHERE COUNTRY IN ('ENGLAND','FRANCE','ITALY')<br />ON TABLE HOLD AS H0 FORMAT ALPHA<br />END<br />-RUN<br />-*<br />TABLE FILE H0<br />SUM<br />COMPUTE CAR/A16 = '';<br />RETAIL_COST<br />COMPUTE RATIO/D10.7S = IF TYPE_NUM EQ 'TYPE 2' THEN RETAIL_COST / (LAST RETAIL_COST) ELSE 0;<br />COMPUTE ORD/A1 = '2';<br />BY TYPE_NUM<br />ON TABLE HOLD AS H1 FORMAT ALPHA<br />END<br />-RUN<br />-*<br />TABLE FILE H0<br />PRINT<br />RETAIL_COST<br />RATIO<br />BY TYPE_NUM<br />BY ORD NOPRINT<br />BY CAR<br />MORE<br />FILE H1<br />END<br />-RUN

August 10, 2005, 03:37 PM
Leah
I may have the ratio calculations backwards to what you want, but this is a method to have different subfoots. Works for two levels anyway.

SET STYLEMODE = FIXED
TABLE FILE CASHFLOW
SUM SHRT_TERM_DEBT NOPRINT
SHRT_TERM_EQUIT NOPRINT
BY QTR
SUM SHRT_TERM_DEBT
SHRT_TERM_EQUIT
BY QTR
BY MONTH
WHERE QTR EQ 'Q1 1998' OR 'Q2 1998'
ON QTR RECAP
RATIOA/D7.3 = ( LAST C1 / C1 ) * 100;
RATIOB/D7.3 = ( LAST C2 / C2 ) * 100;
ON QTR SUBFOOT
" <20> <ST.SHRT_TERM_DEBT <ST.SHRT_TERM_EQUIT "
WHEN QTR EQ 'Q1 1998'
SUBFOOT
" <20> <ST.SHRT_TERM_DEBT <ST.SHRT_TERM_EQUIT <RATIOA <RATIOB "
WHEN QTR EQ 'Q2 1998'
END
August 10, 2005, 03:59 PM
Tim J
Susannah, reFOCUSing and Leah:

Thanks a bunch! I tried the examples and looked at the RECAP command (which I didn't think was this versatile), and I can definitely use any one of these to accomplish what I need to do.

You are all lifesavers!.....and I am in desparate need of a vacation.