<?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: How to use ArcGIS uniqueValues For two Fields in ArcGIS JavaScript API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210859#M78643</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN class=""&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/44467" target="_self"&gt;&lt;SPAN class=""&gt;Kristian &lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;This was quick and helpful~&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 16:56:14 GMT</pubDate>
    <dc:creator>geoca</dc:creator>
    <dc:date>2022-09-08T16:56:14Z</dc:date>
    <item>
      <title>How to use ArcGIS uniqueValues For two Fields in ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210849#M78641</link>
      <description>&lt;P&gt;Using ArcGIS JavaScript API 4.24 and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-statistics-uniqueValues.html" target="_blank" rel="nofollow noopener noreferrer"&gt;uniqueValues&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;esri/smartMapping/statistics/uniqueValues&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;I am able to get&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Count&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of all features in a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;FeatureLayer&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(fcLayer in this code)&lt;/P&gt;&lt;P&gt;In this example respond is based on&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AppType&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field from fcLayer&lt;/P&gt;&lt;PRE&gt;            uniqueValues({
                layer: fcLayer,
                field: "AppType",
            }).then(function(response) {
                let infos = response.uniqueValueInfos;
                infos.forEach(function(info) {
                    console.log("Application Type: ", info.value, " are: ", info.count);
                });
            });&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="geoca_1-1662655253510.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50742iB7E87BB293917469/image-size/medium?v=v2&amp;amp;px=400" role="button" title="geoca_1-1662655253510.png" alt="geoca_1-1662655253510.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now Can you please let me know how I can robust this code in a way that I can group and query two fields&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AppType&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;AppStat &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instead of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field: "AppType"&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;only?&lt;/P&gt;&lt;P&gt;I tried to use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sqlExpression&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sqlWhere&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;instead of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;option like&lt;/P&gt;&lt;PRE&gt;sqlExpression = "AppType = 'RD' AND AppStat = 'active'"
sqlWhere = "AppType = 'RD' AND AppStat = 'active'"&lt;/PRE&gt;&lt;P&gt;in the code like&lt;/P&gt;&lt;PRE&gt;        uniqueValues({
            layer: fcLayer,
            sqlExpression = "AppType = 'RD' AND AppStat = 'active'"
        }).then(function(response) {&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;        uniqueValues({
            layer: fcLayer,
            sqlWhere= "AppType = 'RD' AND AppStat = 'active'"
        }).then(function(response) {&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But none of them returning any thing!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 16:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210849#M78641</guid>
      <dc:creator>geoca</dc:creator>
      <dc:date>2022-09-08T16:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ArcGIS uniqueValues For two Fields in ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210857#M78642</link>
      <description>&lt;P&gt;Getting statistics for two fields like this is not supported at the moment in this function. However, we are adding support for it in our next release.&lt;BR /&gt;&lt;BR /&gt;In the meantime, you can use Query.outStatistics to get the count of features with values from two fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// query for the average of the population change for all features
// Notice that you can pass a SQL expression as a field name to calculate statistics
let statDef = {
  onStatisticField: "CASE WHEN AppType = ‘RD’ AND AppStat = ‘active’ THEN 1 ELSE 0 END", // service field for 2015 population
  outStatisticFieldName: "RD_active",
  statisticType: "sum"
}

let query = layer.createQuery();
query.outStatistics = [ statDef ];

const { features } = await layer.queryFeatures(query);
let stats = features[0].attributes;
console.log("Average change:", stats.RD_active);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 16:55:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210857#M78642</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2022-09-08T16:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ArcGIS uniqueValues For two Fields in ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210859#M78643</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;SPAN class=""&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/44467" target="_self"&gt;&lt;SPAN class=""&gt;Kristian &lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;This was quick and helpful~&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 16:56:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-uniquevalues-for-two-fields-in/m-p/1210859#M78643</guid>
      <dc:creator>geoca</dc:creator>
      <dc:date>2022-09-08T16:56:14Z</dc:date>
    </item>
  </channel>
</rss>

