General,

I think i see what you are doing - let me rephrase what i am looking to achieve.

I have a series of data that comes in monthly.
If the last value is below 50, I want a function that will count how many consecutive months the reading was below 50.
At the same time the function needs to count how many consecutive months the reading was above 50, if the last value was above 50.

So if I have the following data on month 5

month 1: 51
month 2: 49
month 3: 51
month 4: 52
month 5: 53

With the fifth month being the most recent and therefore the starting point.

The function should return a 3.

Now in month 6:

month 1: 51
month 2: 49
month 3: 51
month 4: 52
month 5: 53
month 6: 49

The function needs to return a 1.

Does that help?