<?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: Arcade - how calculate Field in FeatureSet in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183052#M6431</link>
    <description>&lt;P&gt;Also, it should be "esriFieldTypeString", not "esriFieldType&lt;STRONG&gt;s&lt;/STRONG&gt;String".&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 09:15:04 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-06-15T09:15:04Z</dc:date>
    <item>
      <title>Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1120486#M5422</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to get work an Arcade expression to create a FeatureSet, which I want to use then for Serial chart.&lt;BR /&gt;In simplification, I am taking an attribute ZONE from the layer:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;var fs = FeatureSetByPortalItem(Portal('&lt;A href="https://arcgis.com'),'e7ad315d17a742fda44fb63cd311152a',0,['ZONE" target="_blank"&gt;https://arcgis.com'),'e7ad315d17a742fda44fb63cd311152a',0,['ZONE&lt;/A&gt;'], false)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The ZONE attribute is a string which looks like &lt;STRONG&gt;P6-0176&lt;/STRONG&gt;. The goal is to create a field in the FeatureSet which recalculate the ZONE filed but keeps the first two chars only - so the result for this example would be &lt;STRONG&gt;P6&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;So I am creating a new FeatureSet definition, and the attribute&lt;EM&gt; ZONE&lt;/EM&gt; I would like to use in&lt;EM&gt; LEFT&lt;/EM&gt; function.&lt;BR /&gt;But if I use the code like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;var novy = { &lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;'fields': [{'name':'Zona', 'type':'esriFieldTypeString'}], &lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;'geometryType': '', &lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;'features': &lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;[{'attributes': &lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;{'Zona': Left((fs,'ZONE'), 2)&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;}}]};&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;return FeatureSet(Text(novy))&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The result is the error for the LEFT function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the correct syntax to call the column ZONE from the original FeatureSet FS in the LEFT function? Or is there any other way (and this is not the correct one) how to recalculate the ZONE attribute in original FeatureSet FS.&lt;/P&gt;&lt;P&gt;Thank you for any ideas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 19:20:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1120486#M5422</guid>
      <dc:creator>VHolubec</dc:creator>
      <dc:date>2021-11-26T19:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1121163#M5428</link>
      <description>&lt;P&gt;To insert code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1638260465949.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/28505iA3BC9E5D6D9D5830/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1638260465949.png" alt="JohannesLindner_0-1638260465949.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1638260485929.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/28506i5ED9A885086A10AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1638260485929.png" alt="JohannesLindner_1-1638260485929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are trying to input a tuple of (FeatureSet, Text) into the Left function, which is not a valid argument.&lt;/P&gt;&lt;P&gt;According to the &lt;A href="https://developers.arcgis.com/arcade/function-reference/text_functions/#left" target="_blank" rel="noopener"&gt;docs&lt;/A&gt;, the first argument can be Text, Array, Number, or Boolean.&lt;/P&gt;&lt;P&gt;You have to fill your feature set sequencially:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(Portal('https://arcgis.com'),'e7ad315d17a742fda44fb63cd311152a', 0, ['ZONE'], false)

var novy = {
  'fields': [{'name':'Zona', 'type':'esriFieldTypeString'}],
  'geometryType': '',
  'features': []
}
for(var f in fs) {
  var new_f = {'attributes': {'Zona': Left(f.ZONE, 2)}}
  Push(novy.features, new_f)
}
return FeatureSet(Text(novy))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 08:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1121163#M5428</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-11-30T08:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1121647#M5432</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;,&amp;nbsp;it works great!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 10:37:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1121647#M5432</guid>
      <dc:creator>VHolubec</dc:creator>
      <dc:date>2021-12-01T10:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183017#M6429</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thought this would be a suitable thread, I have a very similar requirement. Generating a featureset to use as the data source for a dashboard graph.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var fs = FeatureSetByPortalItem(Portal('https://cityofsydney.maps.arcgis.com'), '103a3484d254440caede4c2a28c46c5b', 9,['StreetSectionArea','StreetFinalForCityReview','STMP2022F1Sp'],false);

var fsfilter = Filter(fs, 'StreetFinalForCityReview = 5')

var F1Sp_GB = Top(OrderBy(GroupBy(fsfilter, ['STMP2022F1Sp'], [ { name: 'SumF1SP', expression: 'StreetSectionArea', statistic: 'SUM' } ]),'SumF1SP DESC'),10)

var TotAreaFinalised = SUM(F1Sp_GB,'SumF1SP')

var joinedDict = {
    
    fields:[
        {'name':'STMP2022F1Sp','type': 'esriFieldTypesString'},
        {'name':'SumF1Sp','type': 'esriFieldTypeBigInteger'},
        {'name':'F1Sp_Per','type': 'esriFieldTypeBigInteger'}],
        'geometryType': '',
        'features':[]
        }
    
for (var f in F1Sp_GB){
    var new_f = {'attributes': {'SPECIES': DomainName(f,"STMP2022F1Sp"),
                                'SPArea': f["SumF1SP"],
                                'SPPer': (f["SumF1SP"]/TotAreaFinalised)*100}}
    Push(joinedDict.features, new_f)
}


return  FeatureSet(Text(joinedDict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;When i return the raw dictionary i can see the correct values, but the featureset does not show when i have the dictionary wrapped inside FeatureSet(Text()).&lt;/P&gt;&lt;P&gt;Can't figure out what i have done wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 06:32:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183017#M6429</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2022-06-15T06:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183050#M6430</link>
      <description>&lt;P&gt;Your field declaration and the fields of your features have to match.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;name&lt;UL&gt;&lt;LI&gt;STMP2022F1Sp, SumF1Sp, F1Sp_Per&lt;/LI&gt;&lt;LI&gt;SPECIES, SPArea, SPPer&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;type&lt;UL&gt;&lt;LI&gt;according to the &lt;A href="https://help.arcgis.com/en/sdk/10.0/java_ao_adf/api/arcgiswebservices/com/esri/arcgisws/EsriFieldType.html" target="_blank" rel="noopener"&gt;docs&lt;/A&gt;, there is no BigInteger, only Integer&lt;/LI&gt;&lt;LI&gt;SPArea and SPPer are probably Double, so either use esriFieldTypeDouble or use Round(x, 0)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 15 Jun 2022 09:13:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183050#M6430</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-06-15T09:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183052#M6431</link>
      <description>&lt;P&gt;Also, it should be "esriFieldTypeString", not "esriFieldType&lt;STRONG&gt;s&lt;/STRONG&gt;String".&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 09:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183052#M6431</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-06-15T09:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183068#M6432</link>
      <description>&lt;P&gt;Thanks so much for your help, it's working now!&lt;/P&gt;&lt;P&gt;Have another question now, the domain name does not get returned, only the code..&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume the f in my loop is the feature in the featureset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;DomainName($feature, 'fieldName')&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 10:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183068#M6432</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2022-06-15T10:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade - how calculate Field in FeatureSet</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183352#M6437</link>
      <description>&lt;P&gt;Figured it out now and i think i understand what was happening...&lt;/P&gt;&lt;P&gt;When i created the variable F1Sp_GB (group by table), it removed the domain... i was just left with the code, to bring back the domain name i had to use the original featureset and insert the code from group by table.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var fs = FeatureSetByPortalItem(Portal('https://cityofsydney.maps.arcgis.com'), '103a3484d254440caede4c2a28c46c5b', 9,['StreetSectionArea','StreetFinalForCityReview','STMP2022F1Sp'],false);

var fsfilter = Filter(fs, 'StreetFinalForCityReview = 5')

var F1Sp_GB = Top(OrderBy(GroupBy(fsfilter, ['STMP2022F1Sp'], [ { name: 'SumF1SP', expression: 'StreetSectionArea', statistic: 'SUM' } ]),'SumF1SP DESC'),10)

var TotAreaFinalised = SUM(F1Sp_GB,'SumF1SP')

var joinedDict = {
    
    fields:[
        {'name':'STMP2022F1Sp','type':'esriFieldTypeString'},
        {'name':'SumF1Sp','type': 'esriFieldTypeDouble'},
        {'name':'F1Sp_Per','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
    
for (var f in F1Sp_GB){
    var new_f = {'attributes': {'STMP2022F1Sp': DomainName(fs,'STMP2022F1Sp',f['STMP2022F1Sp']),
                                'SumF1Sp': round(f['SumF1SP'],0),
                                'F1Sp_Per': round((f['SumF1SP']/TotAreaFinalised)*100,2)}}
    Push(joinedDict.features, new_f)
}


return  FeatureSet(Text(joinedDict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 23:09:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcade-how-calculate-field-in-featureset/m-p/1183352#M6437</guid>
      <dc:creator>PeterMilenkovic</dc:creator>
      <dc:date>2022-06-15T23:09:31Z</dc:date>
    </item>
  </channel>
</rss>

