Hello.

I have a table (say orderlines) with orderrows, There is a column that holds the "Year" of the orderline.

I like to write a userdefine function that calculate how many years in a row that item has been sold from today and back.

For examle :

If I in the table have:

ItemA 2020

ItemA 2020

ItemA 2019

ItemA 2019

ItemA 2019

ItemA 2017

The result is two year (since 2017 is not in a row)

IF I have

ItemB 2019

ItemB 2019

ItemB 2018

ItemB 2018

the result is 0 because it is not sold 2020

How can I accomplish this?