<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retrieve Unique Values from feature layers in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561378#M52408</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyone have any ideas on how to do this in the ArcMap query builder.&amp;nbsp; Say I want to set a definition query on a Feature Service - if I click Get Unique values I can not get a full list due to it being a FS.&amp;nbsp; Seems like ArcMap does not use a distinct call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/207003_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jun 2016 22:18:30 GMT</pubDate>
    <dc:creator>DougBrowning</dc:creator>
    <dc:date>2016-06-06T22:18:30Z</dc:date>
    <item>
      <title>Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561367#M52397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys, i need to retrieve unique values from a set of feature layers. I've been using the following example as a guideline - &lt;A href="http://blogs.esri.com/esri/arcgis/2009/10/07/using-javascript-to-populate-a-combobox-with-unique-values/" title="http://blogs.esri.com/esri/arcgis/2009/10/07/using-javascript-to-populate-a-combobox-with-unique-values/"&gt;Using JavaScript to populate a ComboBox with unique values | ArcGIS Blog&lt;/A&gt; but my problem as noted in that article is that the records i have is over 500, 2500 to be exact. I came across a certain "&lt;A href="https://developers.arcgis.com/javascript/jsapi/query-amd.html#returndistinctvalues" style="color: #00629b; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;returnDistinctValues&lt;/A&gt;" property from the Query API Reference - &lt;A href="https://developers.arcgis.com/javascript/jsapi/query-amd.html" title="https://developers.arcgis.com/javascript/jsapi/query-amd.html"&gt;Query | API Reference | ArcGIS API for JavaScript&lt;/A&gt; which if set to true will return distinct Values of the specified outfields of the query. I haven't tried out as yet since it requires "&lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#supportsadvancedqueries" style="color: #00629b; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;supportsAdvancedQueries&lt;/A&gt;" property of the feature layer to be set to true and the current configuration has it set to false.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I do recognize that changing the maxRecord of the feature layer could severely hamper the performance, so the only other option i can think of using the queryIds method of the feature layer?&lt;/P&gt;&lt;P&gt;Please advise as to which approach i should take to overcome this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 18:08:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561367#M52397</guid>
      <dc:creator>RyanSmith1</dc:creator>
      <dc:date>2015-05-07T18:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561368#M52398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you expect the query to return more than 500 distinct values? That would certainly be a lot for combo box.&amp;nbsp; I did a distinct query on my parcel service for land use codes.&amp;nbsp; My parcel database contains over 100,000 records. The distinct query returned 65 land use categories very quickly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 18:24:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561368#M52398</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-05-07T18:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561369#M52399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom, thanks for your response.&lt;/P&gt;&lt;P&gt;There's 2500 records from the feature layer but currently it's not getting all the unique values because it's only processing the first 1000 records. I'm expecting about 80 - 90 unique values for the combo box. You said that you ran a distinct query, so i need to set returnDistinctValues to true on the query?&lt;/P&gt;&lt;P&gt;*I am using API version 3.13&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 06:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561369#M52399</guid>
      <dc:creator>RyanSmith1</dc:creator>
      <dc:date>2015-05-08T06:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561370#M52400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan,&lt;/P&gt;&lt;P&gt;If you want to check for unique values in all your records (i.e &amp;gt;1000) then try this..&lt;/P&gt;&lt;P&gt; Use the &lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#queryids" style="color: #00629b; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif;"&gt;queryIds(query, callback?, errback?)&lt;/A&gt; method on the feature layer. This method has no limit to the number of records returned from the server + it will return an array of all the object_ids present in your feature class. Once you get the length of all the records present in your feature class, use this object_id array to query for distinct values and populate your final array.&lt;/P&gt;&lt;P&gt;For eg: I have an array length of object_ids = 2500 and at the same time, I'm also aware of the limit of records return from the ArcGIS Server (the default is 1000).&lt;/P&gt;&lt;P&gt;So ill query the first 1000 then the next and then the remain... and in each query ill get the distinct values and sort it in an array.&lt;/P&gt;&lt;P&gt;You will have to implement a logic by which this looping query is done in packets like (1-999,1000-1999,2000-2500).&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nigel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 11:09:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561370#M52400</guid>
      <dc:creator>NigelDsouza</dc:creator>
      <dc:date>2015-05-08T11:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561371#M52401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nigel, &lt;/P&gt;&lt;P&gt;Thanks for this, I'm probably going to use this approach if using the returnDistinctValues property doesn't work. I thought i could avoid the array filtering/querying of object Ids which does affect performance of the application. Surprisingly this hack also didn't work &lt;A href="http://raykendo.com/blog/arcgis-jsapi-hacks-return-distinct/" title="http://raykendo.com/blog/arcgis-jsapi-hacks-return-distinct/"&gt;ArcGIS JavaScript API Hacks: Query Return Distinct - raykendo&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 12:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561371#M52401</guid>
      <dc:creator>RyanSmith1</dc:creator>
      <dc:date>2015-05-08T12:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561372#M52402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The returnDistinctValues works very well.&amp;nbsp; The parcel records service is over 100,000 records and it queries it very quickly.&amp;nbsp; I used the query without a map sample to create demo that you view.&amp;nbsp; The pertinent code for this query is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// query distinct use code values from parcels
var queryTask = new QueryTask("url to your service");


var query = new Query();
query.where = "USE_CODE is not null";&amp;nbsp; // query for non-null values
query.orderByFields = ["USE_CODE"];&amp;nbsp;&amp;nbsp;&amp;nbsp; // sort it so we won't have to later
query.returnGeometry = false;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // turn geometry off, required to be false when using returnDistinctValues
query.returnDistinctValues = true;
query.outFields = ["USE_CODE"];


queryTask.execute(query, showResults);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can view the demo of this at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://gis.yakimawa.gov/demo/distinct.html" title="http://gis.yakimawa.gov/demo/distinct.html" rel="nofollow noopener noreferrer" target="_blank"&gt;Query Distinct Values&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:13:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561372#M52402</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2021-12-12T00:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561373#M52403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Your answer is right. However if I have more than 1000 records and distinct value lies say on the 1001th&amp;lt;&amp;nbsp; record then that value will not show up in the result using just the code you have given cause by default the max records returned by the server will not exceed 1000(This value can be changed).&lt;/P&gt;&lt;P&gt;So Ryan will first have to query the objectids then pass a packet of objectids in the query example you provided for him to get all the distinct values. The query sample you provided will have to be run in a loop untill all the objectids have been queried.&lt;/P&gt;&lt;P&gt;I had the same issue in one of my widgets in Flex so I worked it out this way. Yes the returnGeometry must be turned to false and returnDistinct values to true to optimize the query.&lt;/P&gt;&lt;P&gt;Eg: Once I had to query district names of India which have over 3000 unique Values. If i just simple query on a layer specifying the outField as "dtname", returnDistinctValues =true and returnGeometry= false ill just get 1000.&lt;/P&gt;&lt;P&gt;Hence the above apprach is one way. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nigel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 16:57:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561373#M52403</guid>
      <dc:creator>NigelDsouza</dc:creator>
      <dc:date>2015-05-08T16:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561374#M52404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nigel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are correct.&amp;nbsp; If you are expecting a list of values that exceeds the max count of the service being queried, then you would need to do multiple queries as suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the context of using these values for a combo box, it would seem having a list with that many values for a user to look through might make it difficult to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 17:32:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561374#M52404</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-05-08T17:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561375#M52405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had used a List view and a text box so the user could enter some key words and filter the list.&lt;/P&gt;&lt;P&gt;Somewhat like a autocomplete prompter.&lt;/P&gt;&lt;P&gt;And the list control also helped to make multiple selections.&lt;/P&gt;&lt;P&gt;Maybe we could use a editable combobox in this case what say &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.Actually unless one is very sure that distinct values is going to be less than a 1000 then just your approach is fine. But incase like data just keeps flowing in and it is expected that the distinct values can go over a 1000 then a combination of the two above suggested methods would do great.&lt;/P&gt;&lt;P&gt;I have also tired the combined queries with records less than a 1000 and its performance is almost instantaneous.&lt;/P&gt;&lt;P&gt;- Nigel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 18:04:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561375#M52405</guid>
      <dc:creator>NigelDsouza</dc:creator>
      <dc:date>2015-05-08T18:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561376#M52406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nigel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Agreed!&amp;nbsp; I had used the JQuery listview with the filtering function which works very well.&amp;nbsp; You are correct, the query is almost instantaneous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 18:08:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561376#M52406</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2015-05-08T18:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561377#M52407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys! &lt;/P&gt;&lt;P&gt;I really appreciate your help on this topic. I've merged both approaches into one solution for my application. &lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 May 2015 09:41:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561377#M52407</guid>
      <dc:creator>RyanSmith1</dc:creator>
      <dc:date>2015-05-10T09:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Unique Values from feature layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561378#M52408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyone have any ideas on how to do this in the ArcMap query builder.&amp;nbsp; Say I want to set a definition query on a Feature Service - if I click Get Unique values I can not get a full list due to it being a FS.&amp;nbsp; Seems like ArcMap does not use a distinct call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/207003_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 22:18:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/retrieve-unique-values-from-feature-layers/m-p/561378#M52408</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2016-06-06T22:18:30Z</dc:date>
    </item>
  </channel>
</rss>

