Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Calculation using totals in a "RANKED BY HIGHEST #" report.

 Go Search Notify Tools
 [CLOSED] Calculation using totals in a "RANKED BY HIGHEST #" report.
Member
 posted June 16, 2016 03:15 PM
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,

 Posts: 12 | Registered: June 16, 2016 IP
Virtuoso
 posted June 16, 2016 03:32 PM Hide Post
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

 Posts: 2410 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013 IP
Member
 posted June 16, 2016 04:40 PM Hide Post
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

 Posts: 12 | Registered: June 16, 2016 IP
Virtuoso
 posted June 17, 2016 08:15 AM Hide Post
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
-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

 Posts: 2410 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013 IP