Generate Random Value Based On Assigned Probability Per Group

nfr03

New Member
Joined
Nov 3, 2021
Messages
2
Hi everyone. I would need help in creating a formula to populate a random value of 1 or 0 based on a percentage value assigned per group.

Suppose my data looks something like this. I need to populate the third column with either 1 or 0 on whether that person is part of the sample or not.
PersonIDRegionSelection Value (1 or 0)
1​
A
2​
B
3​
B
4​
C
5​
A


The basis of sample selection is based on a lookup table similar to below. Per region I have a probability for selection.

So for instance 2% of people in Region A would have a value of 1.
98% of people in Region A would have a value of 0.

1% of people in Region B would have a value of 1.
99% of people in Region B would have a value of 0.

And so on....

RegionPercentage to Select (1)Percentage not to Select (0)
A
2%​
98%​
B
1%​
99%​
C
8%​
92%​


Would appreciate any help as I am stuck as of the moment with this.
Thanks a lot!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the MrExcel forum!

How about:

Book2
ABCDEFGHI
1PersonIDRegionSelection Value (1 or 0)RegionPercentage to Select (1)Percentage not to Select (0)
21A0A2%98%
32B1B1%99%
43B0C8%92%
54C1
65A0
7
Sheet9
Cell Formulas
RangeFormula
I2:I4I2=1-H2
C2:C6C2=(RAND()<VLOOKUP(B2,$G$2:$H$4,2,0))+0
 
Upvote 0
Welcome to the MrExcel forum!

How about:

Book2
ABCDEFGHI
1PersonIDRegionSelection Value (1 or 0)RegionPercentage to Select (1)Percentage not to Select (0)
21A0A2%98%
32B1B1%99%
43B0C8%92%
54C1
65A0
7
Sheet9
Cell Formulas
RangeFormula
I2:I4I2=1-H2
C2:C6C2=(RAND()<VLOOKUP(B2,$G$2:$H$4,2,0))+0
Nice. This works exactly as intended. Thank you so much, Eric! ?
 
Upvote 0

Forum statistics

Threads
1,214,388
Messages
6,119,229
Members
448,879
Latest member
VanGirl

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