How to: pick a random subset of table rows

Answering a question on Twitter:

While there is no dedicated transformation for selecting a random subset of rows (yet), it’s relatively simple to do with just a few transformations: calculate new column with a random number, then only keep rows where the random number is below some threshold (which can be defined as a parameter). This method is not very precise but can be sufficient.

In the example a sample dataset is generated. In a real-life case it can be substituted with an import transformation.

Sample project: Random subset.morph (2.8 KB)

1 Like

Here is also an example that picks a subset of rows in a given QVD file.


  1. Open the project
  2. Set parameter “Path to QVD file” (browse to the QVD file that needs to be reduced).
  3. Set subset percentage % (1-99)
  4. Press Run Project (or F5)

Random subset QVD.morph (4.1 KB)