Counting Consecutives

InzieBear

New Member
Joined
Jan 5, 2017
Messages
16
I have a question re formula.

I have a workbook that contains the % of accuracy for each entity.... I.e. Jan to Dec (75%,92%...).

What I want to do is to count the consecutive occurrences where they have failed to meet a target (i.e. 95%) but if they meet the target its reset to zero until the following month where the consecutive would be 1 if they missed.

In the below example there would only be 3 consecutive occurrences (Sep-Nov.) as Aug was 97% so above target so reset the count back to zero. However if I was calculating for Jan - Jul it would have been 7 until August month.

Hope this makes sense....anyone help?
JanFebMarAprMayJunJulAugSepOctNov
75%92%92%75%76%85%76%97%89%70%83%

<tbody>
</tbody><colgroup><col span="11"></colgroup>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Counting consecutive occurrences can be done, but I'm a little unsure about what you want. Do you want a running total of the occurrence? If so, try:

ABCDEFGHIJK
1JanFebMarAprMayJunJulAugSepOctNov
275%92%92%75%76%85%76%97%89%70%83%
312345670123

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
A3=IF(A2<95%,1,0)
B3=IF(B2<95%,A3+1,0)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Put the A3 formula in. Then put the B3 formula in and drag to the right.

Or if you want to find the longest run, this could work:

=MAX(FREQUENCY(IF(A2:K2<95%,COLUMN(A2:K2)),IF(A2:K2>=95%,COLUMN(A2:K2))))
confirmed with Control+Shift+Enter.

Let us know if this works, or if you need something else.
 
Upvote 0
Hey Eric

Thanks for trying to help.

Im trying to do something similar to the first part you described. However, I only want it to show the current month. So (M1) would say "Consecutive Target Miss" then it would only calculate based on the month. Ie if its july it would only do until July. - hope that makes sense.
I did think the If statement it just makes it very long if your only doing it in one coloumn.
 
Upvote 0
If you determine the current month just by which cells have data in them, then maybe:

Excel 2012
ABCDEFGHIJKLM
1JanFebMarAprMayJunJulAugSepOctNovDecConsecutive Target Miss
275%92%92%75%76%85%76%97%89%70%83%3

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
M2{=MAX(IF(ISNUMBER(A2:L2),COLUMN(A2:L2)))-MAX(IF(A2:L2>=95%,COLUMN(A2:L2)))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Hey Eric...this might help a little more. ( im new to this forum so still discovering some things :) )
I need to get the column Consecutive to count the number of consecutive times an entity has missed its target (95%). Once it reach 95% or above, the consecutive goes back to zero...

I have manually done the below to show what I need....can anyone help? In my spreadsheet I have conditional formatting in the Jan-Dec part to show Green for 99%+, Amber for 95%+ and Red for <95% (not sure if this would impact the formula).



Name
JanFebMarApr MayJunJulAugSepOctNovDecConsecutive
Entity 163%97%89%92%63%64%90%92%56%77%97%100%0
Entity 247%64%90%99%86%70%81%67%72%92%83%58%8
Entity 340%45%89%56%72%55%71%84%89%89%86%86%12
Entity 450%47%63%73%58%39%99%29%24%25%69%59%5

<tbody>
</tbody>
 
Upvote 0
This is perfect! Thank you!
However, when I have zero in for Jan to Dec it counts as -55......?


Can I ask....is it possible to manipulate slightly?

Ie can I leave the formula to calculate Jan -Dec and say in April the value May-Dec would be blank...therefore would this still calculate correctly or would it pick up the blanks as being "on target" ?
 
Last edited:
Upvote 0
Actually this doesn't count consecutives. Let me tweak.

Here is custom function if you prefer:

Code:
Function missedTarget(r As Range) As Integer
Dim rng As Range
Dim cell As Range
Dim count As Integer


Set rng = r


count = 0


For Each cell In rng.Cells


    If cell.Value < 0.95 Then
        count = count + 1
    End If
Next


missedTarget = count


End Function
 
Last edited:
Upvote 0
Try this array formula, must be entered with Control-Shift-Enter =12-COUNTBLANK(A2:L2)-MAX(IF(A2:L2>=0.95,COLUMN(A2:L2),0))} copy down
 
Last edited:
Upvote 0
Try this one:

ABCDEFGHIJKLMN
1NameJanFebMarAprMayJunJulAugSepOctNovDecConsecutive
2Entity 163%97%89%92%63%64%90%92%56%77%97%100%0
3Entity 247%64%90%99%86%70%81%67%72%92%83%58%8
4Entity 340%45%89%56%72%55%71%84%89%89%86%86%12
5Entity 450%47%63%73%58%39%99%29%24%25%69%59%5
6Entity 50
7Entity 647%64%90%99%86%70%2
8Entity 740%1
9Entity 850%47%63%73%58%5
10Entity 940%45%89%72%55%71%84%89%89%86%86%12

<tbody>
</tbody>
Sheet9

Array Formulas
CellFormula
N2{=MAX(IF(ISNUMBER(B2:M2),COLUMN(B2:M2)),1)-MAX(IF(B2:M2>=95%,COLUMN(B2:M2)),1)}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



With Entity 9, and April is empty, that counts as a 0%. There should be a good mix of sample data there. Let me know how it works.
 
Last edited:
Upvote 0
Hi Eric,

Thanks for your help. Apologies for the delay. I have been ill.

I have tried the new formula with the ",1" element and now I get -54 instead of -55. Everything else works fine. It just seems to be anything with either 0% or a blank that causes this error.

Any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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