Dear community member
I have a specific use case which I would like to seek some help.
I was given a list of names and groups as below.
| Name | Group |
| John | A |
| Mary | A |
| Peter | A |
| John | B |
| Charles | B |
| Peter | B |
| John | C |
I need create a unique list of names, but at the same time I need to ensure there is at least 1 name in each group.
Mary and Charles are unique in the list; so they are first selected in the output.
John appears in Group A, B, and C. But John is the only person in Group C. Therefore John / Group C must be selected to ensure there are at least 1 participant in each group.
The remainder is Peter, who belongs to both Group A and B. I just randomly select a group for Peter.
The final output will be
| Name | Group |
| Mary | A |
| Charles | B |
| John | C |
| Peter | Randomly choose either A or B |
Could someone please shed some lights on how I can achieve this? I start off with using Unique and sample and rand() but no luck so far.
Thanks in advance.