[
In Column D I want to output random numbers based on entries in Column A.
If an entry in Column A is unique, only occurring once, then the corresponding row in Column D should return a '1'.
If an entry in Column A occurs more than once, as with 'Strawberry' (occurring 2 times), then in this example a random number of '1' or '2' should be returned in their corresponding rows.
Column E & F in the table gives two possible example outcomes that I would expect when the random numbers are regenerated. The COUNT of 'Strawberry' in Column A is 2, and therefore the random numbers in their rows of Column D should be a 1 or a 2. (Note: Both rows returning '2' or both returning '1' would be incorrect. They need to be unique.)
I have made attempts at a solution using Helper Columns in B and C, but it's not working.
Help would be greatly appreciated.
Book2 | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Text String | Column2 | Column1 | Rand | Outcome 1 | Outcome 2 | ||
2 | Apple | 1 | 1 | 1 | 1 | 1 | ||
3 | Banana | 1 | 1 | 1 | 1 | 1 | ||
4 | Strawberry | 2 | #VALUE! | #VALUE! | 2 | 1 | ||
5 | Orange | 1 | 1 | 1 | 1 | 1 | ||
6 | Raspberry | 3 | #VALUE! | #VALUE! | 3 | 2 | ||
7 | Blackberry | 1 | 1 | 1 | 1 | 1 | ||
8 | Strawberry | 2 | #VALUE! | #VALUE! | 1 | 2 | ||
9 | Raspberry | 3 | #VALUE! | #VALUE! | 1 | 3 | ||
10 | Mango | 1 | 1 | 1 | 1 | 1 | ||
11 | Raspberry | 3 | #VALUE! | #VALUE! | 2 | 1 | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B11 | B2 | =COUNTIF([Text String], [@[Text String]]) |
C2:C11 | C2 | =IF(B2>1, RANK.EQ(A2, [Text String], 0) + RANDBETWEEN(0, B2-1), 1) |
D2:D11 | D2 | =IF(B2>1, RANK.EQ(C2, [Column1], 0), 1) |
In Column D I want to output random numbers based on entries in Column A.
If an entry in Column A is unique, only occurring once, then the corresponding row in Column D should return a '1'.
If an entry in Column A occurs more than once, as with 'Strawberry' (occurring 2 times), then in this example a random number of '1' or '2' should be returned in their corresponding rows.
Column E & F in the table gives two possible example outcomes that I would expect when the random numbers are regenerated. The COUNT of 'Strawberry' in Column A is 2, and therefore the random numbers in their rows of Column D should be a 1 or a 2. (Note: Both rows returning '2' or both returning '1' would be incorrect. They need to be unique.)
I have made attempts at a solution using Helper Columns in B and C, but it's not working.
Help would be greatly appreciated.