Focal Point
[CLOSED] Calculation using totals in a "RANKED BY HIGHEST #" report.

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

June 16, 2016, 03:15 PM
CAWarner
[CLOSED] Calculation using totals in a "RANKED BY HIGHEST #" report.
Here is my report code, with field names altered for easy reading:

SET RANK=SPARSE
TABLE FILE STUDENTDATA
SUM CNT.STUDENT_ID NOPRINT
SUM CNT.STUDENT_ID AS '#Enrolled'
COMPUTE PERCENT/F6.2% = (C2/C1)*100; AS "Percent"
RANKED BY TOTAL HIGHEST 10 CNT.STUDENT_ID NOPRINT
BY REFERRING_HIGH_SCHOOL AS 'High School' COLUMN-TOTAL AS 'Total of Top Schools'

The expression (C2/C1) gives me the percentage that each row makes up of the TOTAL number of students. I need to know what percentage it represents out of only the limited list of top ten referring schools. I cannot, for the life of me, figure out how to reference the displayed column-total, which is limited to only the displayed fields.

I haven't found a way to do a separate compute, because I cannot predict that the top ten will have exactly ten entries - ties inflate the list up to potentially 15 (or more).

Any ideas?

Thanks!

This message has been edited. Last edited by: CAWarner,
June 16, 2016, 03:32 PM
MartinY
You cannot reference a total created internally by the matrix.

To perform what you want you need to create the total by yourself, hold it, then merge it to the detailed rows and have both type of line with an unique id type (let say id = 1 for detail and id = 2 for total). Then you'll be able to reference row id=2 as part of your calculation.

Or use other technique such as maybe the MacGyver one. Not sure if it's possible with that method...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
June 16, 2016, 04:40 PM
CAWarner
You got me off the red herring and that was enough for me to puzzle this out for myself. Thanks!


WebFOCUS 8202
Windows, All Outputs
June 17, 2016, 08:15 AM
MartinY
Don't know if may suit your need, but at least it's a start:
SET RANK=SPARSE
-SET &RNK    = 3;
-SET &TOTRNK = 0;

TABLE FILE CAR
SUM CNT.MODEL AS 'CNTDATA'
RANKED BY TOTAL HIGHEST &RNK CNT.MODEL NOPRINT
BY CAR NOPRINT
ON TABLE HOLD AS RNKTOT FORMAT BINARY
END
-RUN
-SET &NBROWS = &LINES;

-REPEAT DOTOT &NBROWS TIMES
-READFILE RNKTOT
-SET &TOTRNK = &TOTRNK + &CNTDATA;
-TYPE &TOTRNK
-DOTOT

TABLE FILE CAR
SUM CNT.MODEL NOPRINT
SUM CNT.MODEL AS 'NbModel'
	COMPUTE PCT/F6.2% = (C2 / C1)      * 100; AS 'Percent'
	COMPUTE PCT/F6.2% = (C2 / &TOTRNK) * 100; AS 'PercentOfRank'
RANKED BY TOTAL HIGHEST &RNK CNT.MODEL
BY CAR
ON TABLE COLUMN-TOTAL AS 'Total' RECOMPUTE
END
-RUN



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007