Google Sheets – How to Select Random Data Points

google sheets

I have a Google spreadsheet document with over 1000 data cells in one column. I want to select 5 random samples from this data set, and copy these to a new column. And repeat this process, n number of times. How do I do this?

Best Answer

To implement sampling without replacement with only spreadsheet functions is not easy. Sampling with replacement is easy enough with randbetween, but if you use it, the samples will change with every edit to the sheet (unless you "stabilize" them by copy-pasting values only, but this is still awkward).

I suggest using an existing solution, such as randomizer.org. It provides a CSV file with random integers in a given range, with or without replacement. The CSV file can be easily imported into Google Sheets: it looks like the table below.

If Randomizer is the name of the sheet with these numbers, and your dataset is in column A of another sheet, then

=offset(A1, Randomizer!A5, 0)

will give the corresponding random element of your list. Copy-paste this command around a 5-by-n range to create the samples.

Note: offset 0 corresponds to the top cell of the data range, so the range of numbers provided to randomizer should begin with 0.

+-------------------------------+-------+-------+
| Research Randomizer Results:  |       |       |
| 20 Sets of 5  Numbers Per Set |       |       |
| Range: From 0 to 999 -- No    |       |       |
| Set 1                         | Set 2 | Set 3 |
| 221                           | 67    | 779   |
| 667                           | 575   | 966   |
| 898                           | 897   | 933   |
| 131                           | 244   | 559   |
| 739                           | 745   | 901   |
+-------------------------------+-------+-------+