Random select from column A with no duplicates in column B

mlanescott

New Member
Joined
Dec 14, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello.
My task is to select 5 REPORT IDs (Column A) without having any duplicates by the Creator Name (Column B).
REPORT IDCreator Name
0003324442Goofy
0003324445Goofy
0003324447Goofy
0003324449Goofy
0003326011Goofy
0003326012Goofy
0003326013Goofy
0003326827Odie
0003328843Odie
0003328849Pluto
0003328853Odie
0003328856Pluto
0003328964Pluto
0003329061Pluto
0003329289Muttley
0003330238Scoobert
0003330239Odie
0003330251Scoobert
0003330261Odie
0003330272Muttley
0003330274Muttley
0003330302Scoobert
0003330303Scoobert
0003330304Snoopy
0003330305Snoopy
0003330343Snoopy
0003333755Bolt
0003333839Odie
0003333840Odie


1607984487984.png


I appreciate you sharing your knowledge!!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the MrExcel board!

Do you have the LET function in your Excel 365?
If so, would this suffice?

20 12 15.xlsm
ABCDE
1REPORT IDCreator Name
20003324442Goofy0003330239Odie
30003324445Goofy0003326013Goofy
40003324447Goofy0003330274Muttley
50003324449Goofy0003330302Scoobert
60003326011Goofy0003330343Snoopy
70003326012Goofy
80003326013Goofy
90003326827Odie
100003328843Odie
110003328849Pluto
120003328853Odie
130003328856Pluto
140003328964Pluto
150003329061Pluto
160003329289Muttley
170003330238Scoobert
180003330239Odie
190003330251Scoobert
200003330261Odie
210003330272Muttley
220003330274Muttley
230003330302Scoobert
240003330303Scoobert
250003330304Snoopy
260003330305Snoopy
270003330343Snoopy
280003333755Bolt
290003333839Odie
300003333840Odie
Random List
Cell Formulas
RangeFormula
D2:E6D2=LET(fltr,FILTER(A$2:B$30,ISNA(MATCH(B$2:B$30,E$1:E1,0))),INDEX(fltr,RANDBETWEEN(1,ROWS(fltr)),0))
Dynamic array formulas.


If no LET function then try
Excel Formula:
=INDEX(FILTER(A$2:B$30,ISNA(MATCH(B$2:B$30,E$1:E1,0))),RANDBETWEEN(1,ROWS(FILTER(A$2:B$30,ISNA(MATCH(B$2:B$30,E$1:E1,0))))),0)
 
Upvote 0
Solution
Apparently I do not have the LET function. Bummer. Using the alternative formula is returning duplicates from Column B.
I will look into what it takes to get the LET function going. In the meantime, is there anything that can be done about duplicates from Column B?
BTW - I feel so honored to have you answering my questions. Thank you!!
 
Upvote 0
Peter's 2nd formula works for me without any duplicates from col B
Did you put it in D2 & fill down?
+Fluff v2.xlsm
ABCDE
1REPORT IDCreator Name
23324442Goofy3328964Pluto
33324445Goofy3326827Odie
43324447Goofy3330272Muttley
53324449Goofy3324442Goofy
63326011Goofy3330304Snoopy
73326012Goofy
83326013Goofy
93326827Odie
103328843Odie
113328849Pluto
123328853Odie
133328856Pluto
143328964Pluto
153329061Pluto
163329289Muttley
173330238Scoobert
183330239Odie
193330251Scoobert
203330261Odie
213330272Muttley
223330274Muttley
233330302Scoobert
243330303Scoobert
253330304Snoopy
263330305Snoopy
273330343Snoopy
283333755Bolt
293333839Odie
303333840Odie
31
Data
Cell Formulas
RangeFormula
D2:E6D2=INDEX(FILTER(A$2:B$30,ISNA(MATCH(B$2:B$30,E$1:E1,0))),RANDBETWEEN(1,ROWS(FILTER(A$2:B$30,ISNA(MATCH(B$2:B$30,E$1:E1,0))))),0)
Dynamic array formulas.
 
Upvote 0
Fluff - you are correct. I applied the formula to my actual data so the output got a little squirrely. Regrettably, I do not entirely understand what the formula is saying so I have to keep it simple. With that in mind, I readjusted and all is well. I'm absolutely ecstatic to have this little trick up my sleeve and can hardly thank Mr. Excel enough!
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0
... can hardly thank Mr. Excel enough!
You just did. :)


I do not entirely understand what the formula is saying
See if we can explain a little. Take this much smaller example where we want 3 at random without creator repeats. Clearly that means we will need 1 drawn from each creator.

20 12 15.xlsm
ABCDE
1REPORT IDCreator Name
20003324442Goofy0003329289Muttley
30003324445Goofy0003330238Scoobert
40003326013Goofy0003326013Goofy
50003329289Muttley
60003330238Scoobert
70003330251Scoobert
Random List (3)
Cell Formulas
RangeFormula
D2:E4D2=INDEX(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E1,0))),RANDBETWEEN(1,ROWS(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E1,0))))),0)
Dynamic array formulas.


Suppose we accept the first result in row 2 and look the formula in D3
=INDEX(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E2,0))),RANDBETWEEN(1,ROWS(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E2,0))))),0)
The two red parts are identical. The underlined part tries to match everything in B2:B7 to values in E1:E2 so it will match the one Muttley but produce errors for the other 5 rows.
The FILTER then will return the original array but with only the error rows, that is 5 rows. The RANDBETWEEN picks a random number from 1 to 5 and chooses that row from this new 5-row array. In this case it chose the first Scoobert row.

Now look at the formula in D4
=INDEX(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E3,0))),RANDBETWEEN(1,ROWS(FILTER(A$2:B$7,ISNA(MATCH(B$2:B$7,E$1:E3,0))))),0)
MATCH tries to match everything in B2:B7 to what is in E1:E3 so it will match the 1 Muttley row and the 2 Scoobert rows and error for the 3 Goofy rows.
The FILTER then will return the original array but with only the error (Goofy) rows (3 rows). The RANDBETWEEN picks a random number from 1 to 3 and chooses that row from this new 3-row array. In this case it chose the third Goofy row.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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