Add distinct function for use with entities

This function or something like it would be useful indeed! It would allow dynamic 'reverse choice filtering' more easily possible.

Currently I am creating a join of all/some of my dataset where a certain field matches (eg for the big entity list, join all site values for my entity items where status = incomplete), and then setting my choice filter on the parent (eg select site) to search the join for matching items and exclude others (so if only Site A, Site C, Site D, Site Z appear in the join, then my choice list for 'select site' will only show these matching options and not other sites that don't have incomplete items).

This results in a join that can be thousands of items in size and is not performant (particularly in Enketo).

An alternate to the search(distinct-values(join())) or however it's implemented, would be as above, eg if a unique nodeset of site values [Site A, Site, C, Site D, Site Z] from the large entity list (biglist.csv) could be created, and the question 'select the site' as select_one_from_file biglist.csv would present these options - using parameters such that value=site, label=site and choice filter like distinct-values(instance('biglist')/root/item[status='incomplete']/site), this removes the need for the parent list(s) altogether (though I'm pretty sure my expression is written incorrectly!)