Hi all,
I want to do a random sampling for multiple categories available in one column. Is there a way to select different number of samples for different category? Please see an example below.
The total amount of samples to select is given by the user via Text Box. Here I have three values under the [group] column, I plan to generate samples for those three groups as evenly as possible. If the user wants to select 7 samples in total but 7 is not divisible by 3, then the output will be 2, 2, 3. So can I use a if-else condition here to set the number accordingly? How to achieve in the analytics app? Thanks in advance!
Hi,
There is a group functionnality in the 'Sample' tool. If you for example select 'First 2 Rows' and then select group by your 'Group' column, it will output the first 2 rows for each unique value in the 'Group' column.
In your case, 2 rows * 3 possible groups -> 6 output rows, 2 from each group.
In the action tool, you can put a floor function to get an equal division between the records.
I attached my workflow, I hope this helps you out,
Louis
Hi Louis,
Thanks very much for your reply. The solution is perfect for a user input that is divisible by 3. Since I would like to select the exact same amount of samples as the user input, there may be different number of samples selected from each category. Say, I select 2 samples for category 1 and 2, but 3 samples for category 3. Is that possible? Thanks!
Regards, Qi
Hi vlad_kutateladze,
Thanks for your solution! I will try out.
Hi Chris,
Thanks for your solution! I will try out.
User | Count |
---|---|
18 | |
14 | |
13 | |
9 | |
8 |