Focal Point
[Solved] Repeating Ranks

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

May 03, 2016, 07:19 PM
Cimmerian
[Solved] Repeating Ranks
I am sorting a sum field descending with limit set to 100 and rank turned on, my goal is to see the top(largest) 100 records.

I've run into a slight issue, if two or more records have the same number they will hold the same ranking place.

Example:

Rank Quantity
1-------18
2-------12
3-------9
---------9
4-------8
5-------2

I don't want 9 to be listed twice under rank 3, I want the first on to display 3 and the second 4.

Example:

Rank Quantity
1-------18
2-------12
3-------9
4-------9
5-------8

(Ignore the dashes, the spaces where getting deleted so I needed to put something there to keep everything spaced correctly)

I only have access to InfoAssist no code, so it must be done entirely in InfoAssist, Any Ideas? Thanks.

This message has been edited. Last edited by: Cimmerian,


WebFocus 8.2, IA+, Windows 10, HTML
May 04, 2016, 07:42 AM
Dave
You have to make your own counter...

...or just put everything in a hold and then use a new table with RECORDLIMIT EQ 100

Good luck,
dave


_____________________
WF: 8.0.0.9 > going 8.2.0.5
May 04, 2016, 03:48 PM
Cimmerian
Thank you for the reply! Could you elaborate on how to make a counter field, I see it in other places in the forum but it uses the word WITH in the define and InfoAssist is not having that.


WebFocus 8.2, IA+, Windows 10, HTML
May 05, 2016, 09:10 AM
Tom Flynn
Cimmerian,
A simplistic way is to use the LIST verb, here is an example(notice the 2nd SORT):

TABLE FILE GGSALES
LIST
DOLLARS
BUDUNITS
BUDDOLLARS
BY CATEGORY
BY HIGHEST DOLLARS NOPRINT
ON TABLE HOLD
END
-RUN
?FF HOLD
-RUN
TABLE FILE HOLD
PRINT *
BY CATEGORY NOPRINT
BY HIGHEST DOLLARS NOPRINT
WHERE LIST LE 100;
END
-EXIT

The other way is to set a counter and reset on the SORT column:

TABLE FILE GGSALES
PRINT
DOLLARS
BUDUNITS
BUDDOLLARS
COMPUTE CNTR/I4 = IF CATEGORY EQ LAST CATEGORY THEN CNTR + 1 ELSE 1;
BY CATEGORY
BY HIGHEST DOLLARS NOPRINT
ON TABLE HOLD
END
-RUN
?FF HOLD
-RUN
TABLE FILE HOLD
PRINT *
BY CATEGORY NOPRINT
BY HIGHEST DOLLARS NOPRINT
WHERE CNTR LE 100;
END
-EXIT

hth


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 05, 2016, 11:13 AM
George Patton
So many ways to do things in WF. Here's another suggestion - a bit more abstruse: Introduce deliberate fractional inequalities in your values.

1) Create a new variable the same as your quantity

2) Use one of the random number subroutines available to create a very small fractional number.

3) Add that to your new variable, so a value like 10 would become 10.000001234 and another 10 would become 10.000005678

4) Run the fex with RANKED BY the new variable NOPRINT

TABLE FILE XYZ
PRINT QUANTITY
RANKED BY NewVariable NOPRINT
....
....
END



WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
May 05, 2016, 11:49 AM
Cimmerian
Thank you for all the replies! I appreciate all the help, I found George Patton's solution to be the most simple (I was overthinking this) and worked like a charm! Thanks again everybody, I will mark this as solved


WebFocus 8.2, IA+, Windows 10, HTML