<?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 Convert A Single FeatureSet Row To A Text String in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1517753#M60762</link>
    <description>&lt;P&gt;Yesterday I learned how to create an Array, sort that array and keep the seconf record from it.&amp;nbsp; Today I wanted to try it using a featureSet as it allowed my to sort on a single numeric field.&amp;nbsp; My successful code is below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// create 50mi buffer on selection
var buff = Buffer($feature,50,'mile')

// get intersecting staff locations
var staff = Intersects(FeatureSetByName($map, "InventoryIntersects"),buff)

// create empty featureset to hold results
var New_FS = {fields:[        
        {'name':'Development_Name','type': 'esriFieldTypeString'},
        {'name':'Project_Address','type': 'esriFieldTypeString'},
        {'name':'Project_City','type': 'esriFieldTypeString'},
        {'name':'Project_State','type': 'esriFieldTypeString'},
        {'name':'Zip_Code','type': 'esriFieldTypeDouble'},
        {'name':'Distance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
 
for (var s in staff){
    var dist = DistanceGeodetic(s,$feature,'miles')
    var distNum = Round(Number(dist),2)
    var dName = s.Development_Name
    var dAddress = s.Project_Address
    var dCity = s.Project_City
    var dState = "TX"
    var zipcode = s.Zip_Code
    var new_f = {'attributes': {'Distance': distNum, 'Zip_Code': zipcode, 'Development_Name': dName, 'Project_Address': dAddress, 'Project_City': dCity, 'Project_State': dState}
                 }
    Push(New_FS.features, new_f)}

var sorted = Top(OrderBy(FeatureSet(Text(New_FS)), 'Distance ASC'),2)
var topTwo = sorted
var filtered = Filter(topTwo, 'Distance &amp;gt; 0')
return filtered&lt;/LI-CODE&gt;&lt;P&gt;which results in:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="results.png" style="width: 690px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/112076iE8188DD593463810/image-size/large?v=v2&amp;amp;px=999" role="button" title="results.png" alt="results.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;results.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way I could simply convert this to a text string so I could use it in a popup like below?&lt;/P&gt;&lt;P&gt;" The location is at Padre De Vida Apartments - 3900 S Ware Rd,&amp;nbsp; McAllen&amp;nbsp; TX 78503 - 1.14 miles"&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;P&gt;GRMapper&lt;/P&gt;</description>
    <pubDate>Fri, 09 Aug 2024 21:56:28 GMT</pubDate>
    <dc:creator>GregReinecke</dc:creator>
    <dc:date>2024-08-09T21:56:28Z</dc:date>
    <item>
      <title>Convert A Single FeatureSet Row To A Text String</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1517753#M60762</link>
      <description>&lt;P&gt;Yesterday I learned how to create an Array, sort that array and keep the seconf record from it.&amp;nbsp; Today I wanted to try it using a featureSet as it allowed my to sort on a single numeric field.&amp;nbsp; My successful code is below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// create 50mi buffer on selection
var buff = Buffer($feature,50,'mile')

// get intersecting staff locations
var staff = Intersects(FeatureSetByName($map, "InventoryIntersects"),buff)

// create empty featureset to hold results
var New_FS = {fields:[        
        {'name':'Development_Name','type': 'esriFieldTypeString'},
        {'name':'Project_Address','type': 'esriFieldTypeString'},
        {'name':'Project_City','type': 'esriFieldTypeString'},
        {'name':'Project_State','type': 'esriFieldTypeString'},
        {'name':'Zip_Code','type': 'esriFieldTypeDouble'},
        {'name':'Distance','type': 'esriFieldTypeDouble'}],
        'geometryType': '',
        'features':[]
        }
 
for (var s in staff){
    var dist = DistanceGeodetic(s,$feature,'miles')
    var distNum = Round(Number(dist),2)
    var dName = s.Development_Name
    var dAddress = s.Project_Address
    var dCity = s.Project_City
    var dState = "TX"
    var zipcode = s.Zip_Code
    var new_f = {'attributes': {'Distance': distNum, 'Zip_Code': zipcode, 'Development_Name': dName, 'Project_Address': dAddress, 'Project_City': dCity, 'Project_State': dState}
                 }
    Push(New_FS.features, new_f)}

var sorted = Top(OrderBy(FeatureSet(Text(New_FS)), 'Distance ASC'),2)
var topTwo = sorted
var filtered = Filter(topTwo, 'Distance &amp;gt; 0')
return filtered&lt;/LI-CODE&gt;&lt;P&gt;which results in:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="results.png" style="width: 690px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/112076iE8188DD593463810/image-size/large?v=v2&amp;amp;px=999" role="button" title="results.png" alt="results.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;results.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there a way I could simply convert this to a text string so I could use it in a popup like below?&lt;/P&gt;&lt;P&gt;" The location is at Padre De Vida Apartments - 3900 S Ware Rd,&amp;nbsp; McAllen&amp;nbsp; TX 78503 - 1.14 miles"&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;P&gt;GRMapper&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 21:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1517753#M60762</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-09T21:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert A Single FeatureSet Row To A Text String</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1517959#M60765</link>
      <description>&lt;P&gt;Thank you Namenbo. I unfortunately don’t follow. I’m hoping to somehow just convert or parse the fields into a text string to put in a popup. Perhaps I have to dump this into an array. Likely more effort than is needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2024 00:53:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1517959#M60765</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-11T00:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert A Single FeatureSet Row To A Text String</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1518339#M60780</link>
      <description>&lt;P&gt;When you've got your filtered FeatureSet, you can then use the function &lt;STRONG&gt;First&lt;/STRONG&gt; to access the first record from the set. Then you can access its attributes directly. Try this at the end of your expression:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// picking up at the end of your expression

var filtered = Filter(topTwo, 'Distance &amp;gt; 0')

var f = First(filtered)

// build output string with a template literal
return `The location is at ${f['Development_Name']} - ${f['Project_Address']}, ${f['Project_City']} ${f['Project_State']} ${f['Zip_Code']} - ${f['Distance']} miles`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:44:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1518339#M60780</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-08-12T13:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert A Single FeatureSet Row To A Text String</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1518343#M60781</link>
      <description>&lt;P&gt;Josh,&lt;/P&gt;&lt;P&gt;I was just digging into the First function and bam you were there to help!!!! It worked perfectly. Thank you so much.&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:48:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/convert-a-single-featureset-row-to-a-text-string/m-p/1518343#M60781</guid>
      <dc:creator>GregReinecke</dc:creator>
      <dc:date>2024-08-12T13:48:39Z</dc:date>
    </item>
  </channel>
</rss>

