AnsweredAssumed Answered

Getting a list of unique values from a field

Question asked by jbo4v on May 28, 2015
Latest reply on Jun 1, 2015 by ebrimhall

I'm trying to retrieve a list of unique values from a particular field in a layer using ArcObjects.

 

I was using the IDataStatistics.UniqueValues, but it causes the results to be corrupted as soon as the function is exited (in ArcMap 10.2+).  I think it's related to some longstanding issues with IDataStatistics (Issues with ArcObjects and ArcGIS 10.1 SP1 IDataStatistics  as an example).

 

I tried using the DISTINCT prefix on the IQueryFilterDefinition2, per the end of the discussion on the last thread, but couldn't get it to work on a shapefile -- It did work on the same data in a File Geodatabase.  What are the limitations of IQueryFilterDefinition2?  Have any other suggestions to get a list of unique values quickly?

 

Some Caveats:

  • It's for commercial software and needs to support ArcMap 10.0-10.3.X
  • We work with all flavors of GeoFeatureLayers and need to support shp, pgdb, fgdb, sde, etc.
  • This function needs to run very quickly, because it's called every time the map refreshes (invalidates) and may be retrieving unique values from one column, from multiple layers with a large number of features each

Outcomes