Finding the nth Occurance of an associate value.

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
519
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Thank you in advance for your assistance.

I have a range of numbers in column B and associated names in column A.

Using the formulas below, I return the 5 lowest numbers in the range. No problem. As long as there arent any duplicate numbers, the associated names are returned. All Ok there too.

However, when then are duplicate or triplicate numbers in column B then only the 1st occurance of the name is returned from column A.

I have tried various, Let, If, etc, type of formulas and do have someting that "kind of works". But I have noticed that there are occasions where the formulas dont work.

Using the number is column B, the names in Column A, I would like to return the names as in row 7.

I have struggled with this for a while, hoping somebody can assist.

Book1
ABCDEFGH
1Occurance
2NameNumber1st2nd3rd4th5th
3A2724455
4B26TGGOO
5C20
6D12Should Be
7E23TGYOZ
8F7
9G4
10H101
11I14
12J13
13K8
14L11
15M10
16N46
17O5
18P9
19Q21
20R17
21S56
22T2
23U14
24V18
25W25
26X20
27Y4
28Z5
Sheet1
Cell Formulas
RangeFormula
D3D3=SMALL($B$3:$B$28,COUNTIF($B$3:$B$28,0)+1)
E3E3=SMALL($B$3:$B$28,COUNTIF($B$3:$B$28,0)+2)
F3F3=SMALL($B$3:$B$28,COUNTIF($B$3:$B$28,0)+3)
G3G3=SMALL($B$3:$B$28,COUNTIF($B$3:$B$28,0)+4)
H3H3=SMALL($B$3:$B$28,COUNTIF($B$3:$B$28,0)+5)
D4:H4D4=INDEX($A:$A,MMULT(SMALL(($B2:$B$28<>D$3)/1%%+ROW($2:$28),1),1))
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
D4:
Code:
=INDEX($A:$A,AGGREGATE(15,6,ROW($B$3:$B$28)/($B$3:$B$28=D3),COUNTIF($D$3:D3,D3)))
drag accross
 
Upvote 0
Another option for 365
Fluff.xlsm
ABCDEFGH
1Occurance
2NameNumber1st2nd3rd4th5th
3A2724455
4B26TGYOZ
5C20
6D12
7E23
8F7
9G4
10H101
11I14
12J13
13K8
14L11
15M10
16N46
17O5
18P9
19Q21
20R17
21S56
22T2
23U14
24V18
25W25
26X20
27Y4
28Z5
Tracker
Cell Formulas
RangeFormula
D3:H3D3=INDEX(SORT(B3:B28),SEQUENCE(,5))
D4:H4D4=INDEX(SORT(A3:B28,2),SEQUENCE(,5),1)
Dynamic array formulas.
 
Upvote 0
.. or this single formula in D3?

22 06 10.xlsm
ABCDEFGH
1Occurance
2NameNumber1st2nd3rd4th5th
3A2724455
4B26TGYOZ
5C20
6D12
7E23
8F7
9G4
10H101
11I14
12J13
13K8
14L11
15M10
16N46
17O5
18P9
19Q21
20R17
21S56
22T2
23U14
24V18
25W25
26X20
27Y4
28Z5
List n Sorted
Cell Formulas
RangeFormula
D3:H4D3=TRANSPOSE(INDEX(SORT(A3:B28,2),SEQUENCE(5),{2,1}))
Dynamic array formulas.
 
Upvote 0
Solution
Hi All,

thank you so very much for your valuable contributions and solutions. I wish I could buy you all a beer or coffee for helping me out. In this case, I went with Peter's solution because when his formula was applied to the real data, it also knocked out several "helper" columns in one go.

I can not emphasis enough my gratitute to you all.

Jeff
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,308
Members
449,151
Latest member
JOOJ

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