Identify rows where value exceeds hurdle consecutively

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,640
Office Version
  1. 365
Platform
  1. Windows
Can someone please help me?

I need a formula for the red column. I wish to identify the rows where the Value equals or exceeds 20 and is part of a streak of at least 4 rows where the Value equals or exceeds 20. Here I used 1s and 0s in a helper column to identify the desired result. Eventually, I would like the formula to be usable in Conditional Formatting and eliminate the need for the helper column.

00 HTML Conversions.xlsm
AB
1streak4
2hurdle20
3
4ValuePart of Streak?
521.01
621.01
721.01
820.01
918.30
1016.70
1122.80
1225.00
130.00
1422.21
1525.01
1628.91
1720.01
1817.80
1916.10
2020.01
2123.31
2230.01
2320.01
2416.10
2515.60
268.90
2713.90
2816.70
2920.01
3022.81
3122.21
3220.61
3322.81
3430.01
Sheet18
 
Last edited by a moderator:
Thanks everyone for all the replies, including Rick, Spiller and Sheetspread. (I don't know why I hadn't been notified by email.)

Peter, I have 43000 rows of data. Using the formula you provided in any column (to make a T/F for each row) slows the speadsheet recalc to a crawl. Using it as a CondFrmt rule does even worse. Frequently, Excel just crashes outright. I suspect it's the IFERROR part combined with the two expanding and contracting ranges.

I sure wish I could figure out an efficient formula to reckon streaks of various lengths across large data sets. Even a Power Query solution would be acceptable. I can't use VBA though, as Rick and Sheetspread suggested in their posts.
 
Last edited:
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can't use VBA

If you say so, but this code worked on a table of 43,000 rows in just a few seconds:

Code:
Sub hilite()
Dim i As Long, j As Long, lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 5 To lr
j = 0
Do Until Cells(i + j, 1) < Range("b2").Value
j = j + 1
Loop
If j >= Range("b1").Value Then
Cells(i, 1).Resize(j).Interior.ColorIndex = 4
i = i + j
Else
End If
Next
End Sub

(the previous version required a variable type change for the larger table and removing the +1 from line 11)
 
Upvote 0
I knew it was a client or coworker's objection rather than any technical limit. I don't have Power Query right now, but try posting to the BI forum with this thread's link if you haven't already.
 
Upvote 0
Peter, I have 43000 rows of data. Using the formula you provided in any column (to make a T/F for each row) slows the speadsheet recalc to a crawl.
See if this is a bit lighter on the resources. For my sample data it re-calculated a 43,000 row range in a few hundredths of a second.

Excel Workbook
AB
1streak4
2hurdle20
3
4ValueStreak?
5160
6130
7411
8271
9411
10231
11160
12430
13350
14370
1540
1650
17291
18241
19461
20341
21431
22441
23150
24460
2540
26281
27261
28441
29361
30190
Streaks (2)
 
Upvote 0
Solution
Peter, that is a vast improvement. Super...thanks tons.

Just so you lot know what I'm on about: I have three practical reasons to pick out streaks. First, on small datasets like the NHL, I want to identify winning & losing streaks for each team in the league. Second, I want to identify heat-waves and cold-snaps in weather data (hence the 43000 rows for daily temps from 1900 onwards). Third and most important, I want to pick out profit streaks for high-frequency stock-market & derivative trading algorithms, which entails millions of rows.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,123
Messages
6,123,182
Members
449,090
Latest member
bes000

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