Focal Point
How to make a Column that counts rows?

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

January 26, 2015, 12:17 PM
Max Nevill
How to make a Column that counts rows?
Hi All.

I am trying to make a recursive count in a column so that effectively each row is numbered. Any suggestions?

Column
1
2
3
4
5
6 (and so on)


WebFocus 8.104
Windows 7 Entreprise, SP1
January 26, 2015, 12:49 PM
Shakila Subhan
Hi Max,
you can use RANKED function to display count in the column.
TABLE FILE CAR
PRINT CAR MODEL 
RANKED BY HIGHEST 5 RETAIL_COST
END



WebFOCUS 8.0.08 - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
Windows, All Outputs
January 26, 2015, 12:59 PM
Tom Flynn
  
TABLE FILE CAR
LIST
    RETAIL_COST
    DEALER_COST
 BY COUNTRY
 BY CAR
END
-EXIT

OR
  
TABLE FILE CAR
SUM
    RETAIL_COST
    DEALER_COST
       COMPUTE CNTR/I3 = CNTR + 1; NOPRINT
 BY TOTAL CNTR
 BY COUNTRY
 BY CAR
END
-EXIT



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
January 26, 2015, 01:02 PM
MartinY
Simply as...

Count up to 10 cars:
DEFINE FILE CAR
ID /I5 = ID + 1;
END
TABLE FILE CAR
BY ID
BY CAR
END


Count up to 18 models:
DEFINE FILE CAR
ID /I5 = ID + 1;
END
TABLE FILE CAR
BY ID
BY MODEL
END


Or to have a count reset on BY:
TABLE FILE CAR
PRINT COMPUTE ID /I5 = IF COUNTRY EQ LAST COUNTRY THEN ID + 1 ELSE 1;
      MODEL
BY COUNTRY
END

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


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
January 26, 2015, 02:02 PM
Max Nevill
Thanks for the replies guys - I got it! Smiler


WebFocus 8.104
Windows 7 Entreprise, SP1