<?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: Arcade popup expression to display related attributes but ignore 0 attribute in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218428#M48174</link>
    <description>&lt;P&gt;Decode might work for you:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;output += TextFormatting.NewLine + related_data_row.StreetNum + " " + related_data_row.Street + " " + Decode(related_data_row.StreetType, "0", "", related_data_row.StreetType) + TextFormatting.Newline + "____________"&lt;/LI-CODE&gt;&lt;P&gt;Assuming StreetType is a text field, if the value is "0", will replace it with "" (blank), if not, uses the value for related_data_row.StreetType.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2022 21:28:18 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2022-10-03T21:28:18Z</dc:date>
    <item>
      <title>Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218420#M48172</link>
      <description>&lt;P&gt;Hello I am trying to display related data in popups using an arcade script I found and altered. The issue is that I need to &lt;STRONG&gt;not return 0&amp;nbsp; or replace 0 with ''&lt;/STRONG&gt;&amp;nbsp;where attribute values are equal to 0. New to Arcade and I have no idea where I would insert a Replace or an if then statement. Right now the following code will show for example &lt;STRONG&gt;5000 State Highway 149 0&lt;/STRONG&gt; as 0 is listed if the feature doesn't have a StreetType value.&amp;nbsp;I have nulls and blanks calculate automatically to be 0 .&amp;nbsp; I cant change the database values to be blank or null for a number of reasons which has to do with comparing values..&lt;/P&gt;&lt;P&gt;var related_table = FeatureSetById($datastore, "12");&lt;BR /&gt;var filter_query = "Asmt = '" + $feature["APN"] + "'";&lt;BR /&gt;var related_data_filtered = Filter(related_table, filter_query);&lt;BR /&gt;var related_data_filtered_count = Count(related_data_filtered);&lt;/P&gt;&lt;P&gt;var output = "";&lt;BR /&gt;if (related_data_filtered_count &amp;gt; 0) {&lt;BR /&gt;output = "Total of " + related_data_filtered_count + " Address(es)";&lt;BR /&gt;for (var related_data_row in related_data_filtered) {&lt;BR /&gt;output += TextFormatting.NewLine + related_data_row.StreetNum + " " + related_data_row.Street + " " + related_data_row.StreetType + TextFormatting.Newline + "____________";&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;output = "No Related Records...";&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:24:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218420#M48172</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-03T21:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218427#M48173</link>
      <description>&lt;P&gt;If the last value is the only one that would be empty, then you can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#isempty" target="_self"&gt;IsEmpty&lt;/A&gt; function to do something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;output += TextFormatting.NewLine + related_data_row.StreetNum + " " + related_data_row.Street;
if (!IsEmpty(related_data_row.StreetType)){
  output += " " + related_data_row.StreetType; 
}
output += TextFormatting.NewLine + "____________";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:31:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218427#M48173</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-10-03T21:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218428#M48174</link>
      <description>&lt;P&gt;Decode might work for you:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;output += TextFormatting.NewLine + related_data_row.StreetNum + " " + related_data_row.Street + " " + Decode(related_data_row.StreetType, "0", "", related_data_row.StreetType) + TextFormatting.Newline + "____________"&lt;/LI-CODE&gt;&lt;P&gt;Assuming StreetType is a text field, if the value is "0", will replace it with "" (blank), if not, uses the value for related_data_row.StreetType.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218428#M48174</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-03T21:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218434#M48176</link>
      <description>&lt;P&gt;I wish your code would work for me because that is exactly what I am trying to do. It is saying&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;Identifier Not Found. related_data_row&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218434#M48176</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-03T21:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218435#M48177</link>
      <description>&lt;P&gt;Well, you're nearly there. What you'd need is something to check the value of each field, then only append it to the output string if it's not a "0". There are &lt;EM&gt;lots&lt;/EM&gt; of ways you could do it, but let's look at using an &lt;STRONG&gt;array &lt;/STRONG&gt;and &lt;STRONG&gt;Erase / &lt;/STRONG&gt;&lt;STRONG&gt;Concatenate&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;By the way, are these layers truly related with a relationship class? You could bypass the filtering step entirely if you used &lt;STRONG&gt;FeatureSetByRelationshipName&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Instead of cobbling the string together all in one go, we can first create an array. Then we can loop through the array and drop any items that are equal to "0". Once our array is "cleaned", we can use concatenate to build that string.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var related_table = FeatureSetById($datastore, "12");
var filter_query = "Asmt = '" + $feature["APN"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);

var output = "";

if (related_data_filtered_count &amp;gt; 0) {
    output = `Total of ${related_data_filtered_count} Address(es)\n`;

    for (var r in related_data_filtered) {
        
        // Array of address parts
        var addr_parts = [
            r.StreetNum,
            r.Street,
            r.StreetType
        ]
        
        // Clean '0' items from array
        for (var part in addr_parts){
            if (addr_parts[part] == '0'){
                Erase(addr_parts, part)
            }
        }
        
        // Create output string
    output += `${Concatenate(addr_parts, ' ')}\n____________`;
    
    }
} else {
output = "No Related Records...";
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:42:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218435#M48177</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-03T21:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218439#M48178</link>
      <description>&lt;P&gt;Yes it is a relationship class a one to many AGOL hosted feature service.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 21:55:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218439#M48178</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-03T21:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218445#M48179</link>
      <description>&lt;P&gt;I tried the above code but it seems to not work or is not supported. Returns nothing in the AGOL popup. Trying to grasp the structure of this code. Never used an array before.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 22:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218445#M48179</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-03T22:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218472#M48180</link>
      <description>&lt;P&gt;Oh, gosh. When I copied my code in, I forgot the last line:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;return output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Add that to the expression I posted, it should return something.&lt;/P&gt;&lt;P&gt;And take a look at &lt;STRONG&gt;FeatureSetByRelationshipName&lt;/STRONG&gt;. When you use that to access the related data, it is pre-filtered to those related items. You'll need to know the relationship name, or use the expression builder to pipe it in.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1664842553282.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52769iC77D087B5B48D942/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1664842553282.png" alt="jcarlson_0-1664842553282.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1664842577055.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52770iE2158112FB093499/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1664842577055.png" alt="jcarlson_1-1664842577055.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 00:16:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1218472#M48180</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-04T00:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219122#M48221</link>
      <description>&lt;P&gt;That seems to do the trick! The only thing I cant figure out is why when the street name is *UNASSIGNED* it just returns the underscores I use to separate the records in the popup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var related_table = FeatureSetByRelationshipName($feature, "Address_Situs");&lt;BR /&gt;var related_table_count = Count(related_table);&lt;/P&gt;&lt;P&gt;var output = "";&lt;/P&gt;&lt;P&gt;if (related_table_count &amp;gt; 0) {&lt;BR /&gt;output = `Total of ${related_table_count} Address(es)\n`;&lt;/P&gt;&lt;P&gt;for (var r in related_table) {&lt;BR /&gt;&lt;BR /&gt;// Array of address parts&lt;BR /&gt;var addr_parts = [&lt;BR /&gt;r.StreetNum,&lt;BR /&gt;r.Street,&lt;BR /&gt;r.StreetType&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;// Clean '0' items from array&lt;BR /&gt;for (var part in addr_parts){&lt;BR /&gt;if (addr_parts[part] == '0'){&lt;BR /&gt;Erase(addr_parts, part)&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;// Create output string&lt;BR /&gt;output += `${Concatenate(addr_parts, ' ')}\n____________` + TextFormatting.NewLine;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;output = "No Related Records...";&lt;BR /&gt;}&lt;BR /&gt;return output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 20:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219122#M48221</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-05T20:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219127#M48222</link>
      <description>&lt;P&gt;Those underscores show up when there is at least 1 related record, regardless of its contents. Do you mean that the street name is literally "UNASSIGNED", or it's null? What's the data look like for rows where this happens?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 21:04:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219127#M48222</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-05T21:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade popup expression to display related attributes but ignore 0 attribute</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219132#M48223</link>
      <description>&lt;P&gt;Literally *UNASSIGNED*. It must have something to do with the * because when the street name is just UNASSIGNED the popup displays UNASSIGNED. This is just old data that came out of an AS400 system. The new data in the new system doesn't have the *&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 21:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-expression-to-display-related/m-p/1219132#M48223</guid>
      <dc:creator>JonathanWhite1</dc:creator>
      <dc:date>2022-10-05T21:14:09Z</dc:date>
    </item>
  </channel>
</rss>

