<?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: Configuring pop-up expression to group by common feature in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1140581#M44144</link>
    <description>&lt;P&gt;Grouping by an attribute could be a bit tricky, but doable. For the sake of having a concise expression, you may wish to take advantage of custom functions.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addToString(string, feat){
    string += `${Text(f.Com_Name)}
    Scientific Name: ${DefaultValue(f.Sci_Name, 'no data')}
    SARO Status: ${DefaultValue(f.SARO_Status, 'no data')}

    `
    return string
}

var popupString = ''

var relatedrecords = FeatureSetByRelationshipName($feature,"Provincially_Tracked_Species_Detail_CRCA");

// return set of distinct taxon values
var taxons = Distinct(relatedrecords('Lower_Taxon'))

for (var t in taxons){
    
    var taxon_name = t.Lower_Taxon
    
    // Add taxon heading to popup string
    popupString += taxon_name + TextFormatting.NewLine
    
    // Filter related records for matching taxon name
    var taxon_records = Filter(relatedrecords, 'Lower_Taxon = @taxon_name')
    
    // Add filtered record details to output string
    for (var f in taxon_records){
        popupString = addToString(popupString, f)
    }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 03 Feb 2022 21:56:19 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-02-03T21:56:19Z</dc:date>
    <item>
      <title>Configuring pop-up expression to group by common feature</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1140560#M44138</link>
      <description>&lt;P&gt;I've created an arcade expression that pulls species data from a related table. Instead of having Lower_Taxon as one of the listed attributes, I'm wondering if I can sort or group the list by it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my current code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var relatedrecords = FeatureSetByRelationshipName($feature,"Provincially_Tracked_Species_Detail_CRCA");
var popupString = ""
for (var f in relatedrecords){
    popupString += Text(f.Com_Name) + TextFormatting.NewLine +
    
        "Scientific Name: " +
        DefaultValue(f.Sci_Name, 'no data') + TextFormatting.NewLine +
        
        "Taxon: " +
        DefaultValue(f.Lower_Taxon, 'no data') + TextFormatting.NewLine +
        
        "SARO Status: " +
        DefaultValue(f.SARO_Status, 'no data') + TextFormatting.NewLine +
        TextFormatting.NewLine
}
return popupString&lt;/LI-CODE&gt;&lt;P&gt;This is what the results look like now:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pop-up Results.JPG" style="width: 321px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33076i48591496C2366860/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pop-up Results.JPG" alt="Pop-up Results.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And this is what I'm hoping for them to look:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pop-up Goal.JPG" style="width: 199px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33077i3F0352D46BBFCFB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Pop-up Goal.JPG" alt="Pop-up Goal.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please let me know if you have any suggestions on how to accomplish this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 21:17:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1140560#M44138</guid>
      <dc:creator>cpenling</dc:creator>
      <dc:date>2022-02-03T21:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Configuring pop-up expression to group by common feature</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1140581#M44144</link>
      <description>&lt;P&gt;Grouping by an attribute could be a bit tricky, but doable. For the sake of having a concise expression, you may wish to take advantage of custom functions.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addToString(string, feat){
    string += `${Text(f.Com_Name)}
    Scientific Name: ${DefaultValue(f.Sci_Name, 'no data')}
    SARO Status: ${DefaultValue(f.SARO_Status, 'no data')}

    `
    return string
}

var popupString = ''

var relatedrecords = FeatureSetByRelationshipName($feature,"Provincially_Tracked_Species_Detail_CRCA");

// return set of distinct taxon values
var taxons = Distinct(relatedrecords('Lower_Taxon'))

for (var t in taxons){
    
    var taxon_name = t.Lower_Taxon
    
    // Add taxon heading to popup string
    popupString += taxon_name + TextFormatting.NewLine
    
    // Filter related records for matching taxon name
    var taxon_records = Filter(relatedrecords, 'Lower_Taxon = @taxon_name')
    
    // Add filtered record details to output string
    for (var f in taxon_records){
        popupString = addToString(popupString, f)
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 03 Feb 2022 21:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1140581#M44144</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-03T21:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Configuring pop-up expression to group by common feature</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1141378#M44185</link>
      <description>&lt;P&gt;Unfortunately, this isn't working for me. It doesn't return anything.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 21:32:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1141378#M44185</guid>
      <dc:creator>cpenling</dc:creator>
      <dc:date>2022-02-07T21:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Configuring pop-up expression to group by common feature</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1282550#M51719</link>
      <description>&lt;P&gt;Did you ever find out how to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 20:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/configuring-pop-up-expression-to-group-by-common/m-p/1282550#M51719</guid>
      <dc:creator>Rice_GIS</dc:creator>
      <dc:date>2023-04-25T20:00:43Z</dc:date>
    </item>
  </channel>
</rss>

