<?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 Removing underscores from single field with a data expression that uses split function in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483270#M9727</link>
    <description>&lt;P&gt;I am trying to remove the underscores from the split field, not all fields. I've been trying to do different things within my data expression but haven't gotten it to work yet.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Split values corresponding to Target
// Reference layer using the FeatureSetByPortalItem() method. 
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'aff5dd7c9615404cac256ec6dc627e10' , 0, ["*"], false);

// Empty dictionary to capture each target reported as separate rows. 
var choicesDict = {'fields': [{ 'name': 'globalid', 'type': 'esriFieldTypeGlobalID'},
                              { 'name': 'Name', 'type': 'esriFieldTypeString'},
                              { 'name': 'Jurisdiction', 'type': 'esriFieldTypeString'},
                              { 'name': 'Community', 'type': 'esriFieldTypeString'}, 
                              { 'name': 'core_capability', 'type': 'esriFieldTypeString'},
                              { 'name': 'split', 'type': 'esriFieldTypeString'},  
                              { 'name': 'Target', 'type': 'esriFieldTypeString'},
                              
                    'geometryType': '', 
                    'features': []}; 

// Split comma separated targets and store in dictionary.
for (var f in fs) {
  var globalid = f["globalid"]
  var Name = f["Name"]
  var Jurisdiction = f["Jurisdiction"]
  var Sub_Jurisdiction = f["Sub_Jurisdiction"]
  var core_capability = f["core_capability"]
  var Target = f["Target"]
  
  var split_array  =  Split(f["target"], ',')
  for(var i in split_array) {
    Push(choicesDict.features, {"attributes":{
                                "globalid": globalid,
                                "Name": Name,
                                "Jurisdiction": Jurisdiction, 
                                "Community": Sub_Jurisdiction,
                                "core_capability": core_capability,
                                "Target": Target,
                                "split": Trim(split_array[i])}})
  }
}

//var result = Replace(choicesDict, "_", " ");

// Convert dictionary to featureSet. 
var fs_dict = FeatureSet(Text(choicesDict));
return fs_dict

//Return featureset after grouping by sub topic 
return GroupBy(fs_dict, ['split'],
     [{ name: 'No', expression: 'split', statistic: 'COUNT' }]);&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dwold_0-1717427812698.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105996iF8657D097D1ED287/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dwold_0-1717427812698.png" alt="dwold_0-1717427812698.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2024 15:19:21 GMT</pubDate>
    <dc:creator>dwold</dc:creator>
    <dc:date>2024-06-03T15:19:21Z</dc:date>
    <item>
      <title>Removing underscores from single field with a data expression that uses split function</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483270#M9727</link>
      <description>&lt;P&gt;I am trying to remove the underscores from the split field, not all fields. I've been trying to do different things within my data expression but haven't gotten it to work yet.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Split values corresponding to Target
// Reference layer using the FeatureSetByPortalItem() method. 
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'aff5dd7c9615404cac256ec6dc627e10' , 0, ["*"], false);

// Empty dictionary to capture each target reported as separate rows. 
var choicesDict = {'fields': [{ 'name': 'globalid', 'type': 'esriFieldTypeGlobalID'},
                              { 'name': 'Name', 'type': 'esriFieldTypeString'},
                              { 'name': 'Jurisdiction', 'type': 'esriFieldTypeString'},
                              { 'name': 'Community', 'type': 'esriFieldTypeString'}, 
                              { 'name': 'core_capability', 'type': 'esriFieldTypeString'},
                              { 'name': 'split', 'type': 'esriFieldTypeString'},  
                              { 'name': 'Target', 'type': 'esriFieldTypeString'},
                              
                    'geometryType': '', 
                    'features': []}; 

// Split comma separated targets and store in dictionary.
for (var f in fs) {
  var globalid = f["globalid"]
  var Name = f["Name"]
  var Jurisdiction = f["Jurisdiction"]
  var Sub_Jurisdiction = f["Sub_Jurisdiction"]
  var core_capability = f["core_capability"]
  var Target = f["Target"]
  
  var split_array  =  Split(f["target"], ',')
  for(var i in split_array) {
    Push(choicesDict.features, {"attributes":{
                                "globalid": globalid,
                                "Name": Name,
                                "Jurisdiction": Jurisdiction, 
                                "Community": Sub_Jurisdiction,
                                "core_capability": core_capability,
                                "Target": Target,
                                "split": Trim(split_array[i])}})
  }
}

//var result = Replace(choicesDict, "_", " ");

// Convert dictionary to featureSet. 
var fs_dict = FeatureSet(Text(choicesDict));
return fs_dict

//Return featureset after grouping by sub topic 
return GroupBy(fs_dict, ['split'],
     [{ name: 'No', expression: 'split', statistic: 'COUNT' }]);&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dwold_0-1717427812698.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105996iF8657D097D1ED287/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dwold_0-1717427812698.png" alt="dwold_0-1717427812698.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 15:19:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483270#M9727</guid>
      <dc:creator>dwold</dc:creator>
      <dc:date>2024-06-03T15:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Removing underscores from single field with a data expression that uses split function</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483275#M9728</link>
      <description>&lt;P&gt;Can you just replace the underscore before you add it to the dictionary?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  for(var i in split_array) {
    var newSplit = Replace(split_array[i], '_', ' ');
    Push(choicesDict.features, {"attributes":{
                                "globalid": globalid,
                                "Name": Name,
                                "Jurisdiction": Jurisdiction, 
                                "Community": Sub_Jurisdiction,
                                "core_capability": core_capability,
                                "Target": Target,
                                "split": Trim(newSplit)}})
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 15:30:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483275#M9728</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-06-03T15:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Removing underscores from single field with a data expression that uses split function</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483394#M9730</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;worked perfectly. Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 18:01:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/removing-underscores-from-single-field-with-a-data/m-p/1483394#M9730</guid>
      <dc:creator>dwold</dc:creator>
      <dc:date>2024-06-03T18:01:10Z</dc:date>
    </item>
  </channel>
</rss>

