Select to view content in your preferred language

How to get the query return distinct values progammatically?

227
2
05-29-2024 09:28 AM
Labels (2)
KTT_Mercury
New Contributor II

Hello - I have searched around and seen this post dated about 1.5 year ago: https://community.esri.com/t5/net-maps-sdk-questions/featuretable-distinct-query/m-p/1253615#M11636

If queryResult is my QueryParameters object, I couldn't find queryResult.ReturnDistinctValues (or something like that)

Up to now, has .Net Maps SDK equivalent of javascript's returnDistinctValues been exposed some where else so I can use it?

Further more, when True radio-button is on for this option in a Feature Service Layer's Query page, I've got some error seen down here:
  

cannot-complete_err.png

 

Return_Distinct_Value_True.png

The Return Distinct Values option has never worked, hasn't it? What am I missing, did the my local administrator forget to turn on something to get it to work ? 

Thanks

0 Kudos
2 Replies
Mike_Quetel
Occasional Contributor

Return Distinct Values at the REST API works, it took me a little trial and error to get it returning results... I found (at the time) that it was poorly documented.  Consider this query against a parking meter layer which proves the layer has a record count of about 40,000 features.  Here is another query that returns the 16 unique values found in the parkingduration field, across those same 40,000+ features.   The critical parameters are (a) use an inclusive where clause that encompasses every row, hence 1=1.  (b) Set the out fields and order by fields to only be the field you want distinct values of (c) set return distinct values to true and (d) set return geometry to false.  The links above should take you the populated query forms which demonstrate the concept.

Concerning your first question, I found that I needed to implement a class to hit the REST api directly as the Maps SDK didn't give me a suitable abstraction for distinct values.

Mike_Quetel
Occasional Contributor

Also, if you do implement your own REST api class, consider the possibility that the number of distinct values returned could exceed the max features allowable per query... so you may have to implement paging logic, which is supported by the RESTI api.

0 Kudos