The Subsample percent of rows analysis enables you to view a random subset of data. This is useful if you need to sample the size of a large dataset. You can also use this analysis to reduce the size of data for a connected map layer while you are defining an analysis workflow. This keeps your data more manageable and improves performance.
Behind the scenes, a percentage of rows is randomly applied to a source layer. The result displays a selection of rows from the selected map layer.
For this guide, let's view reported crime activity located around police stations in Chicago. Since there is a large amount of crime data, let's sample and visualize only 10% percent of the crime data.
Import the template .carto file packaged from "Download resources" of this guide and create the map. Builder opens with Crimes as the first map layer, and Police Stations as the second map layer.
There are several widgets on the dashboard that allow you to filter the crime data. View the widget guides for details about how to create widgets.
From the LAYERS pane, click the Crimes layer.
Click the ANALYSIS tab to add an analysis to the layer.
Apply the Subsample percent of rows analysis.
The result is a sample of your original data that was randomly selected to display approximately 10% of the rows from the Crime dataset.
If you click on the WIDGETS pane, notice that the widgets are still filtering the entire crime dataset,
If you wanted to filter only the sampled data, you could add a new widget to filter by the analysis results,
If you are interested in using the underlying functions in the SQL view of Builder, view the
random() PostgreSQL documentation about mathematical functions.
We would love to hear from you! Was it easy to understand? Do you need more information? Let us know.