<?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: Custom order values in Serial Chart using Arcade. in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1270845#M7520</link>
    <description>&lt;P&gt;In order to loop through your features, you literally need to use a for loop. In Data Expressions, that usually means creating a dictionary and pushing features into it, one by one.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(...)

var out_dict = {
    fields: [{name: 'ultima_consulta_medica', type: 'esriFieldTypeString'}],
    geometryType: '',
    features: []
}

for (var f in fs) {
    
    var new_str = Replace(
        f['ultima_consulta_medica'],
        'Menos de 1 mês',
        '1'
    )
    
    Push(
        out_dict['features'],
        {attributes: {ultima_consulta_medica: new_str}
    )
}

return FeatureSet(Text(out_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There &lt;EM&gt;are &lt;/EM&gt;more efficient ways to do this sort of thing, though, if the data permits it. Does the string "Menos de 1 mes" appear in a consistent position?&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2023 13:31:10 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-03-23T13:31:10Z</dc:date>
    <item>
      <title>Custom order values in Serial Chart using Arcade.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1270611#M7515</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I'm writing a Arcade expression to input data in a serial chart in Dashboards.&lt;/P&gt;&lt;P&gt;The goal is to replace the string values to numbers so I can order the bars and keep the string as the label.&lt;/P&gt;&lt;P&gt;This function retrieves the feature set using FeatureSetByPortalItem, gets the first feature using First, and assigns the value of the 'ultima_consulta_medica' field to the variable ultima_consulta_medica.&lt;/P&gt;&lt;P&gt;The Replace function is then called on ultima_consulta_medica, replacing the string 'Menos de 1 mês' with the number 1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var featureSet = FeatureSetByPortalItem(Portal('myPortal'), 'xxxxx' , 1, ['ultima_consulta_medica'], false);
var feature = First(featureSet);
var ultima_consulta_medica = feature['ultima_consulta_medica'];
ultima_consulta_medica = Replace(ultima_consulta_medica, 'Menos de 1 mês', '1');

return ultima_consulta_medica;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was stuck trying to make the expression loop through all the values of the ultima_consulta_medica. I need the end result to replace the string with '1'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also don't know if my approach was the best way to resolve my problem.&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 20:20:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1270611#M7515</guid>
      <dc:creator>CodexRemote</dc:creator>
      <dc:date>2023-03-22T20:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Custom order values in Serial Chart using Arcade.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1270845#M7520</link>
      <description>&lt;P&gt;In order to loop through your features, you literally need to use a for loop. In Data Expressions, that usually means creating a dictionary and pushing features into it, one by one.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(...)

var out_dict = {
    fields: [{name: 'ultima_consulta_medica', type: 'esriFieldTypeString'}],
    geometryType: '',
    features: []
}

for (var f in fs) {
    
    var new_str = Replace(
        f['ultima_consulta_medica'],
        'Menos de 1 mês',
        '1'
    )
    
    Push(
        out_dict['features'],
        {attributes: {ultima_consulta_medica: new_str}
    )
}

return FeatureSet(Text(out_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There &lt;EM&gt;are &lt;/EM&gt;more efficient ways to do this sort of thing, though, if the data permits it. Does the string "Menos de 1 mes" appear in a consistent position?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 13:31:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1270845#M7520</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-03-23T13:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom order values in Serial Chart using Arcade.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302381#M7996</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;Josh--&lt;BR /&gt;&lt;BR /&gt;What might be more efficient ways? I am dealing with this problem on a feature view from a survey (therefore cannot edit the layer to add, say, a sequence number to sort the bars). An image is below. As you can see, things are out of order.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LydiaYoungblood_0-1687511732122.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74022iC123C8E97A05E1E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LydiaYoungblood_0-1687511732122.png" alt="LydiaYoungblood_0-1687511732122.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for any ideas!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 09:20:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302381#M7996</guid>
      <dc:creator>AnnaScholl</dc:creator>
      <dc:date>2023-06-23T09:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Custom order values in Serial Chart using Arcade.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302440#M7998</link>
      <description>&lt;P&gt;With data expressions, you can easily add new "fields" to the output, even if they do not exist in the input. You could add a new field, "sequence_number", and when you use the &lt;STRONG&gt;Push &lt;/STRONG&gt;function to add a new feature to the output, include an expression like &lt;STRONG&gt;Decode&lt;/STRONG&gt; that can convert your text values to a number.&lt;/P&gt;&lt;P&gt;Then just use that numeric value to sort the chart data!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 13:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302440#M7998</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-23T13:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Custom order values in Serial Chart using Arcade.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302885#M8010</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;. Thank you! Do you happen to know if there is an example code in the master? I've had a look but couldn't find anything. This seems like something that should be quite easy, but I am a complete beginner, so I am not really sure how to proceed.&amp;nbsp;&lt;A href="https://github.com/Esri/arcade-expressions/tree/master" target="_blank" rel="noopener"&gt;https://github.com/Esri/arcade-expressions/tree/master&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 09:50:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/custom-order-values-in-serial-chart-using-arcade/m-p/1302885#M8010</guid>
      <dc:creator>AnnaScholl</dc:creator>
      <dc:date>2023-06-26T09:50:41Z</dc:date>
    </item>
  </channel>
</rss>

