Jarmo's response is the correct answer, if the Lots are always contiguous. However, if the grouping column is not contiguous, such as
A
A
A
B
B
A
A
C
C
C
then the provided formulas will not be correct. Here are alternative formulas that handle noncontiguous groupings
Down
As Constant( count = 0 );
If( :Lot != Lag( :Lot ),
count
++);
count;
Up
As Constant(
count = 0;
For Each Row( If( :Lot != Lag( :Lot ), count++ ) );
count = count + 1;
);
If( :Lot != Lag( :Lot ),
count
--);
count;
Middle
As Constant(
count = 0;
For Each Row( If( :Lot != Lag( :Lot ), count++ ) );
count = count + 1;
count = -1 * Ceiling( count / 2 );
);
If( :Lot != Lag( :Lot ),
count
++);
count;
Jim