I am using QGIS 2.18.19. I have a layer that shows 800+ different locations throughout the city. I want to randomly select say 30 locations using the Random Selection tool. It works great as is when there is no filter on. but once I apply a filter to the layer it would only select a random 10 locations even though I specified 30 in the "Number of selected features" box.
The Random Selection tool doesn't seem to recognize when a layer is filtered. This is a bug. View the bug report to check the current status of this issue.
Here's a workaround using the Random Selection within Subset tool.
Now all the feature that would have been displayed with that filter, have a "Filter" value of 1. Features that would have been hidden have a "Filter" value of 0.
Run the Random Selection within Subset tool. Where it asks for an ID Field, select the "Filter" field.
Now it selects the desired number of features within the displayed features. It also attempts to select the same number of features within the hidden features, but those features are filtered out so it shouldn't affect any of the outcome.
Note: If you change the filter query, you must also update the "Filter" field.
UPDATE to bug report:
Fixed in master/backported to 3.2
-Presumably this means the issue is fixed in version 3.2, but will persist in earlier versions.