I am trying to find for each customer the Max consecutive years he buys something. I tried to create a calculated field but to no avail. I created two calculated fields

Consecutive: if max([Count])>0 then previous_value(0)+1+index()-index() else 0 end

max: window_max([Consecutive])

My data looks something like:

Year | Customer | Count

1996 | a | 2

1996 | b | 1

1997 | a | 1

1997 | b | 2

1998 | b | 1

So the result would be

a:2

b:3