<?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: Using a When() Statement for a select_multiple in Dashboard List in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-a-when-statement-for-a-select-multiple-in/m-p/1283134#M7704</link>
    <description>&lt;P&gt;&lt;SPAN&gt;To post code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1677736512957.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64138iBB0E7839D9513E0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1677736512957.png" alt="JohannesLindner_0-1677736512957.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1677736529803.png" style="width: 661px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64139i1EE5AE3E3AEE8247/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1677736529803.png" alt="JohannesLindner_1-1677736529803.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;However, the syntax is different when doing the code for pop-ups versus in the Dashboard List&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;The main difference is that you have to return a Featureset for Dashboard elements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let me start by saying this: If all you're doing is removing the underscores, you're making it much too complicated. Your popup expression could look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// replace underscore with space
return Replace($feature["WORKERS_ASSIGNED"], "_", " ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, a data expression that goes through your Survey layer and replaces the underscores in the WORKERS_ASSIGNED field could look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// this is my test data
//var fs = {geometryType:"",fields:[{name:"WORKERS_ASSIGNED",type:"esriFieldTypeString"}, {name:"X",type:"esriFieldTypeInteger"}],features:[{attributes:{WORKERS_ASSIGNED:"Joe_Biden", X:46}},{attributes:{WORKERS_ASSIGNED:"Donald_Trump", X:45}},{attributes:{WORKERS_ASSIGNED:"Barack_Obama", X:44}},{attributes:{WORKERS_ASSIGNED:"George_W_Bush", X:43}},{attributes:{WORKERS_ASSIGNED:"Bill_Clinton", X:42}},{attributes:{WORKERS_ASSIGNED:"George_H_W_Bush", X:41}},{attributes:{WORKERS_ASSIGNED:"Ronald_Reagan", X:40}}]}
//fs = Featureset(Text(fs))

// load your Layer
var fs = FeaturesetByPortalItem(...)

// Copy the schema of your layer into a new emppty Featureset
var fs_schema = Schema(fs)
var out_fs = {
    geometryType: fs_schema.geometryType,
    fields: fs_schema.fields,
    features: []
}

// loop over your Layer's features
for(var f in fs) {
    // get the attributes
    var att = Dictionary(Text(f)).attributes
    // replace underscores
    att.WORKERS_ASSIGNED = Replace(att.WORKERS_ASSIGNED, "_", " ")
    // append the edited feature to the output featureset
    Push(out_fs.features, {geometry: Geometry(f), attributes: att})
}

// return the output featureset
return Featureset(Text(out_fs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Be sure that you actually load your Layer in line 6. Using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem" target="_blank" rel="noopener"&gt;FeaturesetByPortalItem&lt;/A&gt; function, you also can limit the fields you want to import.&lt;/P&gt;&lt;P&gt;This is my test input&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1682550694724.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69239i7435B1171F62582D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1682550694724.png" alt="JohannesLindner_0-1682550694724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the output it created&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1682550746847.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69240i0BBAAA692F2BEBF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1682550746847.png" alt="JohannesLindner_1-1682550746847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Apr 2023 23:16:26 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-04-26T23:16:26Z</dc:date>
    <item>
      <title>Using a When() Statement for a select_multiple in Dashboard List</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-a-when-statement-for-a-select-multiple-in/m-p/1283032#M7703</link>
      <description>&lt;P&gt;I was able to create a When() statement in Arcade for the ArcGIS Online pop-up of a Work Order hosted feature class that displays the workers' names without the underscore in the name and puts each new name on a separate line.&amp;nbsp; I am trying to recreate this in Dashboard, since Arcade cannot be done in Experience Builder Lists.&amp;nbsp; However, the syntax is different when doing the code for pop-ups versus in the Dashboard List.&amp;nbsp; Can someone please help me determine how to do it, if possible?&amp;nbsp; The current setup looks something like this:&lt;/P&gt;&lt;P&gt;var worker = $feature["WORKERS_ASSIGNED"]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;When(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;worker == 'Worker_One',"Worker One",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;worker == 'Worker_Two',"Worker Two",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;worker == 'Worker_Three',"Worker Three",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;"Unknown")&lt;/P&gt;&lt;P&gt;Depending on which worker(s) are chosen, the names show up in the pop-up as:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Worker One&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Worker Two&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Worker Three&lt;/P&gt;&lt;P&gt;My reasoning for doing this is so the names look nicely formatted in the app List (whether in Dashboard or Experience Builder), instead of having a list like Worker_One,Worker_Two,Worker_Three.&amp;nbsp; I currently have a field for each worker name (~25) that formats the name in Survey123 Connect, but I'd love to be able to get rid of those extra fields.&amp;nbsp; This is the only way I've found that might allow me to do this.&amp;nbsp; Any advice is welcome!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 20:08:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-a-when-statement-for-a-select-multiple-in/m-p/1283032#M7703</guid>
      <dc:creator>JasminePrater</dc:creator>
      <dc:date>2023-04-26T20:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using a When() Statement for a select_multiple in Dashboard List</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/using-a-when-statement-for-a-select-multiple-in/m-p/1283134#M7704</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To post code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1677736512957.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64138iBB0E7839D9513E0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1677736512957.png" alt="JohannesLindner_0-1677736512957.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1677736529803.png" style="width: 661px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64139i1EE5AE3E3AEE8247/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1677736529803.png" alt="JohannesLindner_1-1677736529803.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;However, the syntax is different when doing the code for pop-ups versus in the Dashboard List&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;The main difference is that you have to return a Featureset for Dashboard elements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let me start by saying this: If all you're doing is removing the underscores, you're making it much too complicated. Your popup expression could look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// replace underscore with space
return Replace($feature["WORKERS_ASSIGNED"], "_", " ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, a data expression that goes through your Survey layer and replaces the underscores in the WORKERS_ASSIGNED field could look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// this is my test data
//var fs = {geometryType:"",fields:[{name:"WORKERS_ASSIGNED",type:"esriFieldTypeString"}, {name:"X",type:"esriFieldTypeInteger"}],features:[{attributes:{WORKERS_ASSIGNED:"Joe_Biden", X:46}},{attributes:{WORKERS_ASSIGNED:"Donald_Trump", X:45}},{attributes:{WORKERS_ASSIGNED:"Barack_Obama", X:44}},{attributes:{WORKERS_ASSIGNED:"George_W_Bush", X:43}},{attributes:{WORKERS_ASSIGNED:"Bill_Clinton", X:42}},{attributes:{WORKERS_ASSIGNED:"George_H_W_Bush", X:41}},{attributes:{WORKERS_ASSIGNED:"Ronald_Reagan", X:40}}]}
//fs = Featureset(Text(fs))

// load your Layer
var fs = FeaturesetByPortalItem(...)

// Copy the schema of your layer into a new emppty Featureset
var fs_schema = Schema(fs)
var out_fs = {
    geometryType: fs_schema.geometryType,
    fields: fs_schema.fields,
    features: []
}

// loop over your Layer's features
for(var f in fs) {
    // get the attributes
    var att = Dictionary(Text(f)).attributes
    // replace underscores
    att.WORKERS_ASSIGNED = Replace(att.WORKERS_ASSIGNED, "_", " ")
    // append the edited feature to the output featureset
    Push(out_fs.features, {geometry: Geometry(f), attributes: att})
}

// return the output featureset
return Featureset(Text(out_fs))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Be sure that you actually load your Layer in line 6. Using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem" target="_blank" rel="noopener"&gt;FeaturesetByPortalItem&lt;/A&gt; function, you also can limit the fields you want to import.&lt;/P&gt;&lt;P&gt;This is my test input&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1682550694724.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69239i7435B1171F62582D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1682550694724.png" alt="JohannesLindner_0-1682550694724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the output it created&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1682550746847.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69240i0BBAAA692F2BEBF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1682550746847.png" alt="JohannesLindner_1-1682550746847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 23:16:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/using-a-when-statement-for-a-select-multiple-in/m-p/1283134#M7704</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-04-26T23:16:26Z</dc:date>
    </item>
  </channel>
</rss>

