Need help counting consecutive duplicate values

winds

Board Regular
Joined
Mar 9, 2022
Messages
69
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. MacOS
Hello. I have a column which will have a bunch of 1's, 2's and 3's in random order and I want to know the max number of times the 1's, 2's and 3's occur consecutively. Can anyone help me devise such a formula?
 

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"
MrExcelPlayground7.xlsx
ABCD
1312
2321
3134
42
51
61
72
83
91
101
113
122
131
142
151
162
173
183
193
202
213
223
233
243
251
263
271
282
291
302
Sheet20
Cell Formulas
RangeFormula
A1:A30A1=RANDARRAY(30,1,1,3,TRUE)
D1:D3D1=LEN(MAX(FILTERXML("<x><y>"&SUBSTITUTE(TRIM(CONCAT(IF(A$1#=C1,1," ")))," ","</y><y>")&"</y></x>","//y")))
Dynamic array formulas.
 
Upvote 0
Hmm this looks exactly what I want, but when I copy paste the formula my excel can't seem to recognise it.. any ideas why that seems to be the case?

I get this error as displayed in the image.

I also can't seem to copy paste the sheet above into my excel. The numbers in Column A doesn't seem to come out.
 

Attachments

  • Screen Shot 2022-03-19 at 8.56.11 AM.png
    Screen Shot 2022-03-19 at 8.56.11 AM.png
    79.5 KB · Views: 6
Last edited:
Upvote 0
any ideas why that seems to be the case?
That's because the filterxml function doesn't exist on a Mac.
How about
+Fluff 1.xlsm
ABCD
1212
2323
3336
43
53
63
73
82
92
103
113
121
131
142
153
161
172
183
192
201
212
222
232
241
252
262
271
282
293
302
Master
Cell Formulas
RangeFormula
D1:D3D1=MAX((FREQUENCY(IF($A$1:$A$30=C1,ROW($A$1:$A$30)),IF($A$1:$A$30<>C1,ROW($A$1:$A$30)))))
 
Upvote 0
Solution
That's because the filterxml function doesn't exist on a Mac.
How about
+Fluff 1.xlsm
ABCD
1212
2323
3336
43
53
63
73
82
92
103
113
121
131
142
153
161
172
183
192
201
212
222
232
241
252
262
271
282
293
302
Master
Cell Formulas
RangeFormula
D1:D3D1=MAX((FREQUENCY(IF($A$1:$A$30=C1,ROW($A$1:$A$30)),IF($A$1:$A$30<>C1,ROW($A$1:$A$30)))))
Hmm now I'm getting the "#VALUE!" error in my cell where I have inputted the formula. I tried copy pasting the sheet above and it also gives me the "#VALUE!" error as well. Any ideas why this is happening?
 
Upvote 0
Forgot to mention that you will need to confirm the formula with Ctrl Shift Enter, rather than just Enter.
 
Upvote 0
Forgot to mention that you will need to confirm the formula with Ctrl Shift Enter, rather than just Enter.

Wow it works! Now one more question, how do I adjust that formula so that if it is 1, 2, or 3, it will calculate that trend as well. The different number would be 0. For example if the order in the column is 1,1,2,2,3,3,0,0,1,1,2,0,2,3,1,0 in this case the highest 'trend' is 6
 
Upvote 0
Try this, still confirmed with C+S+E

Excel Formula:
=MAX((FREQUENCY(IF($A$1:$A$16<>0,ROW($A$1:$A$16)),IF($A$1:$A$16=0,ROW($A$1:$A$16)))))
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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