<?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 to return field names that contain a string in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208115#M47636</link>
    <description>&lt;P&gt;$feature is iterable, which each iteration is a field.&amp;nbsp; This might help&lt;/P&gt;&lt;P&gt;* Edit, I think using the Schema function is safer, updated code to use it instead of looping over $feature&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fields = [];
var values = [];
var all_fields = Schema($feature)['fields'];
for (var i in all_fields){
    var field_dict = all_fields[i]
    var x = field_dict['name']
    Push(fields,x)
    push(values, $feature[x])
}
return values&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2022 12:40:35 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2022-08-31T12:40:35Z</dc:date>
    <item>
      <title>Arcade to return field names that contain a string</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208092#M47635</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I'm fairly new to Arcade and programming and I've got myself a bit stuck so would welcome any help!&lt;/P&gt;&lt;P&gt;In AGOL, I have a hosted feature layer that I'm using in a Dashboard. I want to add in indicators that do some calculations e.g. sum, minimum, maximum.&lt;/P&gt;&lt;P&gt;However, the dataset has a lot of fields that I don't really want to manually list out. The fields that will be used in the calculations all have field names that have the prefix "D_". I am able to create the result I want by listing the fields used in the calculation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fields = [
$datapoint["D_20210913"],
$datapoint["D_20210925"],
$datapoint["D_20211007"],
$datapoint["D_20211019"],
$datapoint["D_20211031"],
$datapoint["D_20211112"],
$datapoint["D_20211124"],
...
]
var minimum = min(fields)
var rounded = Round(minimum,3)

return {...}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm wondering is, is it possible to use Find and a For loop etc. to list out all the fields that have field names containing "D_"?&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;I'd appreciate any help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 12:10:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208092#M47635</guid>
      <dc:creator>abrown8</dc:creator>
      <dc:date>2022-08-31T12:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade to return field names that contain a string</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208115#M47636</link>
      <description>&lt;P&gt;$feature is iterable, which each iteration is a field.&amp;nbsp; This might help&lt;/P&gt;&lt;P&gt;* Edit, I think using the Schema function is safer, updated code to use it instead of looping over $feature&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fields = [];
var values = [];
var all_fields = Schema($feature)['fields'];
for (var i in all_fields){
    var field_dict = all_fields[i]
    var x = field_dict['name']
    Push(fields,x)
    push(values, $feature[x])
}
return values&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 12:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208115#M47636</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2022-08-31T12:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade to return field names that contain a string</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208123#M47637</link>
      <description>&lt;P&gt;Building on &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt; 's excellent Schema method to subset your fields for those with "D_" in the name, include something like this in the main for loop:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// other stuff above...
    var x = field_dict['name']
    if (Left(x, 2) == 'D_'){    
        Push(fields,x) 
        Push(values, $feature[x])
    }
}

return min(values)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 13:00:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208123#M47637</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-31T13:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade to return field names that contain a string</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208133#M47638</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/188597"&gt;@MikeMillerGIS&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;Thank you for your help, it's greatly appreciated! That's worked wonders.&lt;/P&gt;&lt;P&gt;I wasn't aware of the Push function so I've learned something new&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 13:18:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-to-return-field-names-that-contain-a-string/m-p/1208133#M47638</guid>
      <dc:creator>abrown8</dc:creator>
      <dc:date>2022-08-31T13:18:49Z</dc:date>
    </item>
  </channel>
</rss>

