Count consecutive values starting from last zero in row

cholcfp

New Member
Joined
May 2, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet where I need to calculate the consecutive months in a row where a site is showing up 'flagged' as a 1. This needs to restart every time they show up as 0 (i.e, fall off the flagged list). The max frequency formulas I have tried from other forums don't work as they return the max consecutive values despite the site falling off in current month(s).
 

Attachments

  • Screenshot 2023-05-02 135015.png
    Screenshot 2023-05-02 135015.png
    11.9 KB · Views: 16

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi & welcome to MrExcel.
How about
Excel Formula:
=13-LOOKUP(2,1/(B2:M2=0),COLUMN(B2:M2))
 
Upvote 0
Hi & welcome to MrExcel.
How about
Excel Formula:
=13-LOOKUP(2,1/(B2:M2=0),COLUMN(B2:M2))
Hi! Thanks for the quick reply! This worked for most rows - but did not return expected results on rows 7 & 8, screenshot attached.
 

Attachments

  • Screenshot 2023-05-02 140844.png
    Screenshot 2023-05-02 140844.png
    17.5 KB · Views: 10
Upvote 0
I forgot to account for a row with no zeros, so I have corrected that, but the two rows you have flagged should work
Fluff.xlsm
ABCDEFGHIJKLMNO
1
21111100000000
30111111100011
Master
Cell Formulas
RangeFormula
O2:O3O2=IFNA(13-LOOKUP(2,1/(B2:M2=0),COLUMN(B2:M2)),12)


Check that those 0 are real numbers & not text.
 
Upvote 0
I forgot to account for a row with no zeros, so I have corrected that, but the two rows you have flagged should work
Fluff.xlsm
ABCDEFGHIJKLMNO
1
21111100000000
30111111100011
Master
Cell Formulas
RangeFormula
O2:O3O2=IFNA(13-LOOKUP(2,1/(B2:M2=0),COLUMN(B2:M2)),12)


Check that those 0 are real numbers & not text.
Thank you! That works on my slimmed down sample data, but can't figure out what I need to change in my larger data set that has 25 months and will be adding additional month as year progresses. I tried to simply adjust 13 to 26 and 12 to 25, but it's returning negative values so I am definitely not doing something correct.
 

Attachments

  • Screenshot 2023-05-02 143009.png
    Screenshot 2023-05-02 143009.png
    19.6 KB · Views: 8
Upvote 0
Ok, how about
Excel Formula:
=LET(Data,D2:AB2,c,COLUMNS(Data),IFNA(LOOKUP(2,1/(Data=0),SEQUENCE(,c,c-1,-1)),c))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

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