Often you may want to select a random sample from a dataset in Google Sheets. Fortunately this is easy to do using the RAND() function, which generates a random number between 0 and 1.
The following step-by-step example shows how to use this function to select a random sample in Google Sheets.
Step 1: Create a Dataset
First, we’ll enter the values of a dataset into a single column:
Step 2: Create a List of Random Values
Next, type =RAND() into cell B2. This creates a random value between 0 and 1.
Copy and paste this formula into every remaining cell in column B:
Step 3: Copy & Paste the Random Values
Next, highlight the values in column B and click Ctrl + C. This will copy all of the values. Next, right click on cell C2 and choose Paste special > Paste values only.
Note that the values in column B may change once you do this, but don’t worry about this.
Lastly, highlight the values in column C and drag them to replace the values in column B.
Step 4: Sort by the Random Values
Next, highlight cells A2:B16. Then click the Data tab along the top ribbon, then click Sort range.
Choose to sort by the values of Column B from A to Z, then click Sort:
The values will be sorted based on the random number, from smallest to largest:
Step 5: Select the Random Sample
Lastly, choose the first n rows to be in your random sample. For example, if you want a random sample of size 5, then choose the first 5 raw data values to be included in your sample.
In this example, our random sample would include the first 5 values: 5, 20, 14, 13, 8.
The following tutorials explain how to select a random sample from a dataset using other statistical software: