Return most common number

JustBEBE

New Member
Joined
Jan 5, 2023
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
Hi, I need some help with a formula as I am stuck and can’t think anymore for a solution…let me explain what I need:

I have a col A1:A200 with 200 numbers from 1-20 that keeps repeating. In cell B1 I will add a number (5 for example).

I need a formula to give me the 3 most common numbers that are in the row underneath the number 5 out of the 200 numbers in col A1:A200.


A B
2 5
1
5
4
9
5
19
7
5
19
16
5
3

In the example above as you can see, number 19 is twice under number 5, so I need excel to give me that number (but top 3 numbers that are most common out of 200 numbers if possible)

Can someone help please? Thanks in advance!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Book1
ABC
18Top 3Frequency
241315
36414
412512
515
610
716
82
910
106
119
124
1311
1410
154
168
1710
188
199
208
216
227
2314
2410
2520
265
276
282
2919
3014
318
3210
332
3413
3512
3616
3713
3815
3911
4018
4111
427
4313
4418
4519
4614
4718
4820
497
5020
5119
5217
5319
5416
555
569
5719
5812
5914
604
6113
6217
6318
6417
6517
6611
675
687
694
704
714
726
733
7414
7520
765
775
789
794
8020
814
8213
831
8418
859
864
8715
884
8913
908
911
9218
935
943
952
9614
9720
982
9916
1006
10117
10213
1039
1043
1059
10619
1072
10812
10911
1105
1113
1124
11317
1141
1156
11613
11717
1186
1193
12016
1217
12215
12316
12413
1252
12611
1277
12815
1291
1301
1311
1322
13313
1345
13520
1361
1375
13820
13911
14017
1411
14216
14317
14413
1452
14620
14714
14814
14919
15020
15118
15216
1538
1543
15519
15613
1574
15817
15910
1608
16118
1628
16315
16413
16518
16618
1675
16816
1691
1703
1713
1724
17313
1741
17520
1769
1777
17811
17918
18014
18115
18217
1833
18415
1851
1866
1875
1881
18916
19011
19118
1929
1937
1945
19514
1968
19717
19813
19916
20010
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=MODE(IF(ISERROR(MATCH($A$1:$A$200,B$1:B1,0)),$A$1:$A$200))
C2:C4C2=COUNTIF($A$1:$A$200,B2)
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$1:$A$200B2:C4
 
Upvote 0
Book1
ABC
18Top 3Frequency
241315
36414
412512
515
610
716
82
910
106
119
124
1311
1410
154
168
1710
188
199
208
216
227
2314
2410
2520
265
276
282
2919
3014
318
3210
332
3413
3512
3616
3713
3815
3911
4018
4111
427
4313
4418
4519
4614
4718
4820
497
5020
5119
5217
5319
5416
555
569
5719
5812
5914
604
6113
6217
6318
6417
6517
6611
675
687
694
704
714
726
733
7414
7520
765
775
789
794
8020
814
8213
831
8418
859
864
8715
884
8913
908
911
9218
935
943
952
9614
9720
982
9916
1006
10117
10213
1039
1043
1059
10619
1072
10812
10911
1105
1113
1124
11317
1141
1156
11613
11717
1186
1193
12016
1217
12215
12316
12413
1252
12611
1277
12815
1291
1301
1311
1322
13313
1345
13520
1361
1375
13820
13911
14017
1411
14216
14317
14413
1452
14620
14714
14814
14919
15020
15118
15216
1538
1543
15519
15613
1574
15817
15910
1608
16118
1628
16315
16413
16518
16618
1675
16816
1691
1703
1713
1724
17313
1741
17520
1769
1777
17811
17918
18014
18115
18217
1833
18415
1851
1866
1875
1881
18916
19011
19118
1929
1937
1945
19514
1968
19717
19813
19916
20010
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=MODE(IF(ISERROR(MATCH($A$1:$A$200,B$1:B1,0)),$A$1:$A$200))
C2:C4C2=COUNTIF($A$1:$A$200,B2)
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$1:$A$200B2:C4
Hi @kevin9999
I think what OP is asking for is, finding the top e most accuring numbers after a certain value. For ex. 19 occured twice after 5. Maybe other numbers occurred more than 19 did. Which 3 are the most frequent? But the condition is, they must appear right after 5. (Or any other pre-defined value)
 
Upvote 0
Hi @kevin9999
I think what OP is asking for is, finding the top e most accuring numbers after a certain value. For ex. 19 occured twice after 5. Maybe other numbers occurred more than 19 did. Which 3 are the most frequent? But the condition is, they must appear right after 5. (Or any other pre-defined value)
Yes, you're right, I read it too quickly. I've switched off for tonight but be my guest 🙂
 
Upvote 0
I need a formula to give me the 3 most common numbers that are in the row underneath the number 5
If you have all the latest functions, see if this does what you want. (Colour was just for my own benefit for checking)

23 01 05.xlsm
ABC
18Top 3Frequency
2494
35163
412202
515
65
716
82
910
106
115
124
1311
1410
155
169
1710
188
199
205
219
227
2314
2410
2520
265
276
282
2919
3014
318
3210
332
3413
3512
3616
3713
3815
3911
4018
4111
427
4313
4418
4519
4614
4718
4820
497
5020
5119
5217
5319
5416
555
569
5719
5812
5914
604
6113
6217
6318
6417
6517
6611
675
687
694
704
714
726
733
7414
7520
767
775
789
794
8020
814
8213
831
8418
859
864
8715
884
8913
908
911
9218
935
9416
952
9614
9720
982
9916
1006
10117
10213
1039
1043
1059
10619
1072
10812
10911
1105
1113
1124
11317
1141
1156
11613
11717
1186
1193
12016
1217
12215
12316
12413
1252
12611
1277
12815
1291
1301
1311
1322
13313
1345
13520
1361
1375
13820
13911
14017
1411
14216
14317
14413
1452
14620
14714
14814
14919
15020
15118
15216
1538
1543
15519
15613
1574
15817
15910
1608
16118
1628
16315
16413
16518
16618
1675
16816
1691
1703
1713
1724
17313
1741
17520
1769
1777
17811
17918
18014
18115
18217
1833
18415
1851
1866
1875
1881
18916
19011
19118
1929
1937
1945
19514
1968
19717
19813
19916
20010
Sheet2 (3)
Cell Formulas
RangeFormula
B2:C4B2=LET(u,UNIQUE(FILTER(A2:A200,A1:A199=5)),TAKE(SORT(HSTACK(u,COUNTIFS(A2:A200,u,A1:A199,5)),2,-1),3))
Dynamic array formulas.
 
Upvote 0
Paste this formula to D2:
Excel Formula:
=MODE(IF(ISERROR(MATCH(IF($A$1:$A$200=$B$1,$A$2:$A$201),D$1:D1;0)),IF($A$1:$A$200=$B$1,$A$2:$A$201)))
Unfortunately, this formula counts the values only occurring more than once.
 
Upvote 0
Solution
Paste this formula to D2:
Excel Formula:
=MODE(IF(ISERROR(MATCH(IF($A$1:$A$200=$B$1,$A$2:$A$201),D$1:D1;0)),IF($A$1:$A$200=$B$1,$A$2:$A$201)))
Unfortunately, this formula counts the values only occurring more than once.
First of all I want to thank all of you for helping in this matter! You guys are great skilled!! @Flashbond this was working great! Exactly what I was looking for! Thanks a million.

I also tried @Peter_SSs yours but is giving me some error and I didn’t identified it yet, I will check and if not sorting I will ask you to help :D. Thanks @kevin9999 for trying, maybe I wasn’t the best at explaining after whole night trying to make it work with no success…buy anyway, thanks again you all for getting into this and for help!! Is working and is great!
 
Upvote 0
If you have all the latest functions, see if this does what you want. (Colour was just for my own benefit for checking)

23 01 05.xlsm
ABC
18Top 3Frequency
2494
35163
412202
515
65
716
82
910
106
115
124
1311
1410
155
169
1710
188
199
205
219
227
2314
2410
2520
265
276
282
2919
3014
318
3210
332
3413
3512
3616
3713
3815
3911
4018
4111
427
4313
4418
4519
4614
4718
4820
497
5020
5119
5217
5319
5416
555
569
5719
5812
5914
604
6113
6217
6318
6417
6517
6611
675
687
694
704
714
726
733
7414
7520
767
775
789
794
8020
814
8213
831
8418
859
864
8715
884
8913
908
911
9218
935
9416
952
9614
9720
982
9916
1006
10117
10213
1039
1043
1059
10619
1072
10812
10911
1105
1113
1124
11317
1141
1156
11613
11717
1186
1193
12016
1217
12215
12316
12413
1252
12611
1277
12815
1291
1301
1311
1322
13313
1345
13520
1361
1375
13820
13911
14017
1411
14216
14317
14413
1452
14620
14714
14814
14919
15020
15118
15216
1538
1543
15519
15613
1574
15817
15910
1608
16118
1628
16315
16413
16518
16618
1675
16816
1691
1703
1713
1724
17313
1741
17520
1769
1777
17811
17918
18014
18115
18217
1833
18415
1851
1866
1875
1881
18916
19011
19118
1929
1937
1945
19514
1968
19717
19813
19916
20010
Sheet2 (3)
Cell Formulas
RangeFormula
B2:C4B2=LET(u,UNIQUE(FILTER(A2:A200,A1:A199=5)),TAKE(SORT(HSTACK(u,COUNTIFS(A2:A200,u,A1:A199,5)),2,-1),3))
Dynamic array formulas.
I’ve just seen now, you said if I have all the latest functions, so I think that’s the reason is not working for me, I don’t think I have them…but thanks for your time! I appreciate
 
Last edited by a moderator:
Upvote 0
First of all I want to thank all of you for helping in this matter! You guys are great skilled!! @Flashbond this was working great! Exactly what I was looking for! Thanks a million.

I also tried @Peter_SSs yours but is giving me some error and I didn’t identified it yet, I will check and if not sorting I will ask you to help :D. Thanks @kevin9999 for trying, maybe I wasn’t the best at explaining after whole night trying to make it work with no success…buy anyway, thanks again you all for getting into this and for help!! Is working and is great!
Ahh sorry, I forgot a semicolon there because of my regional settings but I guess you've figured it out already :) Happy for it did help :)
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

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