Count Consecutive Cells

chicubs

New Member
Joined
Aug 10, 2016
Messages
8
I am trying to count the current consecutive weeks an item is below its average for a given period of time starting with the past week. Not sure how to do this. Item 123 should have an output of 3 since it has been below the average the past 3 weeks. Item 1234 should have an output of 0 since it was above the average last week.

Item10/2010/2711/311/10AvgConsecutive WK Below Avg
123158769???
12341514101513???

<tbody>
</tbody>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
What if you had the below scenario?


Item10/2010/2711/311/10AvgConsecutive WK Below Avg
123451581069???

<tbody>
</tbody>
 
Upvote 0
Assuming "Item" is in A1, This should work: =COLUMN(E2)-IF(B2:E2<F2,1,LARGE(IF(B2:e2>=F2,COLUMN(B2:E2)),1))<F2,1,LARGE(IF(B2:e2>

EDIT: corrected a mistake with the formula.

=COLUMN(E2)-IF(B2:E2<F2,1,LARGE(IF(B2:E2>=F2,COLUMN(B2:E2)),1))</F2,1,LARGE(IF(B2:e2></F2,1,LARGE(IF(B2:e2>
 
Last edited:
Upvote 0
Assuming "Item" is in A1, This should work: =COLUMN(E2)-IF(B2:E2<F2,1,LARGE(IF(B2:e2>=F2,COLUMN(B2:E2)),1))<F2,1,LARGE(IF(B2:e2>

EDIT: corrected a mistake with the formula.

=COLUMN(E2)-IF(B2:E2<F2,1,LARGE(IF(B2:e2>=F2,COLUMN(B2:E2)),1))</F2,1,LARGE(IF(B2:e2></F2,1,LARGE(IF(B2:e2>
Use this one: =COLUMN(E2)-IF(B2:E2 < F2,1,LARGE(IF(B2:E2>=F2,COLUMN(B2:E2)),1))

delete the spaces before and after "<"


</F2,1,LARGE(IF(B2:e2>
 
Last edited:
Upvote 0
Thanks! Conversely, what formula would work to count the consecutive weeks ABOVE the average?
 
Upvote 0
Forgot to tell you its an array formula (CRTL-SHIFT-ENTER), though I guess you figured it out.

Thanks! Conversely, what formula would work to count the consecutive weeks ABOVE the average?
I'll get back to you as soon as I can,might be tomorrow morning
 
Upvote 0
Thanks! Conversely, what formula would work to count the consecutive weeks ABOVE the average?

Hey chicubs, did some more testing with the last formula I gave you, it might seems like it works but it has some weaknesses/mistakes. Sorry for it, these should be without failure:

Consecutives weeks below average: =IFERROR(COLUMN(E2)-LARGE(IF(B2:E2>=F2,COLUMN(B2:E2)),1),COUNTA(B2:E2))
Consecutives weeks above average: =IFERROR(COLUMN(E2)-LARGE(IF(B2:E2 < F2,COLUMN(B2:E2)),1),COUNTA(B2:E2))

Confirm both with CTRL-SHIFT-ENTER
 
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,320
Members
448,887
Latest member
AirOliver

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top