Add distinct function for use with entities

What high-level problem are you trying to solve?

With entities now available, there are some form logic operations that cannot be achieved with the existing set of form functions. i.e.

The "trees" dataset, which is populated with entities created from a form "Tree registration form".

In the form "Tree follow-up Form", we want to filter down the "trees" dataset by the property "species", so in a subsequent question a user only has a limited number of options to select from. We want this to dynamically respond to entities with new species in the dataset, rather than having to update the definition.

There is not currently a way to build a distinct list of "tree/species" directly within the form to use in a select_one question.
This can be solved by utilising multiple datasets, i.e. "trees" & "species", however this adds complexity to manage, especially since a form can currently only create a single entity.

Previously, this type of distinct operation was rolled into the form definition ( e.g. using Excel functions), however entities should remove the need to update definitions for this reason.

Any ideas on how ODK could help you solve it?

By adding the function distinct-values
This would allow for a nodeset that contains only the "species" values to be calculated, and the distinct values of that nodeset used in the select_one question.

Alternatively, by extending support for regular expressions to allow groups, not just a boolean as the result of the calculation.

Upload any helpful links, sketches, and videos.