CAS 6


User function: sequence

Function orders each repeating value in the field. Ordering starts at zero.

Example

    sequence FIELD

Sequencing numeric fields may return unexpected results when the data contains decimal places. Rounding to the nearest reasonable whole number or decimal may be prudent.

Rate Example

Data

    0.000000
    6.875000
    7.500001
    6.875000
    6.875021
    6.875000
    7.875000
    7.375009
    6.875000   

Rounded Input

    sequence .125 round  RATE

Description

    Data =   C A D D A C D B D C B A B B A
    Result = 0 0 0 1 1 1 2 0 3 2 1 2 2 3 3

Breaking down value "C" you can see the sequence below

Value Order Description
C 0 First
A 0
D 0
D 1
A 1
C 1 Second
D 2
B 0
D 3
C 2 Third
B 1
A 2
B 2
B 3
A 3