Focal Point
[SOLVED]Recordlimit for each unique BY fieldname

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

July 06, 2015, 10:52 AM
Michele Brooks
[SOLVED]Recordlimit for each unique BY fieldname
I am doing the following Table File Request and need to limit the number of records to the first 5 records each time the clno changes (each unique clno). Thanks.

TABLE FILE HOLDFILE
SUM PAYMENTS
BY CLNO PAGE-BREAK REPAGE NOPRINT
BY DESCRIPTION
END

Windows Operating System
WF Developer Studio 8009

This message has been edited. Last edited by: Michele Brooks,
July 06, 2015, 10:56 AM
Francis Mariani
If DESCRIPTION is the "differentiator" field, then BY LOWEST 5 DESCRIPTION might work...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 06, 2015, 06:18 PM
Waz
If any of the other BY HIGHEST/LOWEST don't work, then COMPUTE a counter and use WHERE TOTAL counter LE 5.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

July 06, 2015, 10:18 PM
Michele Brooks
Lowest 5 will only give me the lowest 5 for the first clno only. Thank you for your suggestion. I figured out the following solution. This solution will start the list count with 1 every time the clno changes. This allows me to capture the first 5 records for each unique clno.

 
TABLE FILE HOLD1
LIST *
BY CLNO PAGE-BREAK REPAGE
ON TABLE HOLD AS HOLD2 FORMAT ALPHA
END
DEFINE FILE HOLD2
RECORD_COUNT/I5 = LIST;
END
TABLE FILE HOLD2
SUM
BY CLNO PAGE-BREAK REPAGE NOPRINT
WHERE RECORD_COUNT LE 5
END




WF 8205, Windows 10
Oracle DBMS
EXL07/PDF Output
July 07, 2015, 10:08 AM
Francis Mariani
Michelle, because there is a BY statement before the BY LOWEST you should get 5 rows for every CLNO.

This seems to work:

SET BYDISPLAY=ON
TABLE FILE GGPRODS
SUM
SIZE
BY PACKAGE_TYPE
BY LOWEST 3 PRODUCT_DESCRIPTION
END

Package Product        Size 
------- -------------- ----
Case    Biscotti       24 
Case    Coffee Grinder 12 
Case    Coffee Pot      8 
Pounds  French Roast   12 
Pounds  Hazelnut       16 
Pounds  Kona           12




Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 07, 2015, 12:45 PM
George Patton
That's nice Michelle. I didn't know that you could use LIST as a variable name afte using it as a command. I wonder if RANKED BY works the same ...


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
July 07, 2015, 05:55 PM
Waz
Yes you can, but as it is a reserved word, you can't use it in the TABLE request.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

July 08, 2015, 10:02 AM
George Patton
quote:
TABLE FILE HOLD1
LIST *
BY CLNO PAGE-BREAK REPAGE
ON TABLE HOLD AS HOLD2 FORMAT ALPHA
END
DEFINE FILE HOLD2
RECORD_COUNT/I5 = LIST;
END


Michelle uses LIST (a reserved word) in her define. You think that if I put something like
RECORD_NUMBER/I5=RANK;
in a define it won't work? Maybe I'll give it a try. There's one routine I run every 6 months where it might be useful.


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP