<?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: Attribute rule arcade statement in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528217#M1546</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346604"&gt;@Brian_McLeer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2024 21:01:49 GMT</pubDate>
    <dc:creator>EricBregant2</dc:creator>
    <dc:date>2024-08-27T21:01:49Z</dc:date>
    <item>
      <title>Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528188#M1544</link>
      <description>&lt;P&gt;Hello! I am working on an attribute rule that will concatenate 6 fields that make up a street address to create a full address. The problem is that 2 of the fields are not always populated with a value. They will either be null or empty.&lt;/P&gt;&lt;P&gt;In the image below, you can see my 6 fields (ST_NUM, DIRPRE, FEANME, FEATYP, DIRSUF and Unit (LV_APT)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-08-27 132256.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/113658iDF3C5B6898A5E084/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-08-27 132256.jpg" alt="Screenshot 2024-08-27 132256.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I do a simple concatenate of tho&lt;/SPAN&gt;&lt;SPAN&gt;se fields,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the result will leave spaces at the end of the full address. I know this is because of there not always being a value in DIRSUF or LV_APT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have been working on the below code, but I know I am missing some parts. Any ideas or anyone know a better way?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// List the fields to combine&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, $feature.DIRSUF, $feature.LV_APT];&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;// Loop through the address parts, if not null or empty add them to a new array&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var filteredparts = [];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;for (var i in parts) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; var value = parts[i];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; if (IsEmpty(value)) continue;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; filteredparts[Count(filteredparts)] = value&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;// Concatenate with a space&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return Concatenate(filteredparts, " ");&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 20:33:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528188#M1544</guid>
      <dc:creator>EricBregant2</dc:creator>
      <dc:date>2024-08-27T20:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528209#M1545</link>
      <description>&lt;P&gt;I think you have to add the "" function to check for if a part is empty.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// List the fields to combine
var parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, $feature.DIRSUF, $feature.LV_APT];

// Function to check if a value is null or empty
function IsNullOrEmpty(value) {
    return value == null || value == "";
}

// Loop through the address parts, if not null or empty add them to a new array
var filteredparts = [];
for (var i in parts) {
    var value = parts[i];
    if (IsNullOrEmpty(value)) continue;
    filteredparts[Count(filteredparts)] = value;
}

// Concatenate with a space
return Concatenate(filteredparts, " ");&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 27 Aug 2024 20:51:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528209#M1545</guid>
      <dc:creator>Brian_McLeer</dc:creator>
      <dc:date>2024-08-27T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528217#M1546</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346604"&gt;@Brian_McLeer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 21:01:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528217#M1546</guid>
      <dc:creator>EricBregant2</dc:creator>
      <dc:date>2024-08-27T21:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528231#M1547</link>
      <description>Take a look at &lt;A href="https://developers.arcgis.com/arcade/function-reference/array_functions/#filter" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/array_functions/#filter&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Aug 2024 21:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528231#M1547</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-08-27T21:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528234#M1548</link>
      <description>&lt;P&gt;I found this as well&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;var fullName&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;if(IsEmpty($feature.ST_NUM)==false){&lt;BR /&gt;fullName += $feature.ST_NUM + " "&lt;BR /&gt;}&lt;BR /&gt;if(IsEmpty($feature.DIRPRE)==false){&lt;BR /&gt;fullName += $feature.DIRPRE + " "&lt;BR /&gt;}&lt;BR /&gt;if(IsEmpty($feature.FEANME)==false){&lt;BR /&gt;fullName += $feature.FEANME + " "&lt;BR /&gt;}&lt;BR /&gt;if(IsEmpty($feature.FEATYP)==false){&lt;BR /&gt;fullName += $feature.FEATYP + " "&lt;BR /&gt;}&lt;BR /&gt;if(IsEmpty($feature.DIRSUF)==false){&lt;BR /&gt;fullName += $feature.DIRSUF + " "&lt;BR /&gt;}&lt;BR /&gt;if(IsEmpty($feature.LV_APT)==false){&lt;BR /&gt;fullName += $feature.LV_APT + " "&lt;BR /&gt;}&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;return fullName&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 21:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528234#M1548</guid>
      <dc:creator>EricBregant2</dc:creator>
      <dc:date>2024-08-27T21:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528251#M1549</link>
      <description>&lt;P&gt;You may need to adapt your code filter out strings with spaces.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;IsEmpty(null) // true
IsEmpty("") // true
IsEmpty(" ") // false&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 21:57:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528251#M1549</guid>
      <dc:creator>TedHoward2</dc:creator>
      <dc:date>2024-08-27T21:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528260#M1550</link>
      <description>&lt;P&gt;Here is how we do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function not_empty(x) {
  return !IsEmpty(x);
}
return Concatenate(Filter(['a', 'b', '', null,'c'], not_empty), '-');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;returns&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"a-b-c"&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 22:21:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528260#M1550</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-08-27T22:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528262#M1551</link>
      <description>&lt;P&gt;If you want to handle "&amp;nbsp; ", then change not_empty to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function not_empty(x) {
  if (TypeOf(x) == 'String'){
    x = Trim(x)
  }
  return !IsEmpty(x);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 22:25:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528262#M1551</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-08-27T22:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528903#M1554</link>
      <description>&lt;P&gt;I got the below code to do everything I want except to add an "#" before the unit number ($feature.LV_APT).&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// List the fields to combine&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, $feature.LV_APT];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// Function to check if a value is null or empty&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;function IsNullOrEmpty(value) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return value == null || value == "";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// Loop through the address parts, if not null or empty add them to a new array&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var filteredparts = [];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;for (var i in parts) {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var value = parts[i];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (IsNullOrEmpty(value)) continue;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Push(filteredparts, value); // Use Push to add elements&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;// Concatenate with a space&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var finaladdress = Concatenate(filteredparts, " ")&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return finaladdress;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 18:29:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528903#M1554</guid>
      <dc:creator>EricBregant2</dc:creator>
      <dc:date>2024-08-28T18:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528941#M1555</link>
      <description>&lt;P&gt;// List the fields to combine&lt;BR /&gt;var parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, $feature.LV_APT];&lt;/P&gt;&lt;P&gt;// Function to check if a value is null or empty&lt;BR /&gt;function IsNullOrEmpty(value) {&lt;BR /&gt;return value == null || value == "";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Loop through the address parts, if not null or empty add them to a new array&lt;BR /&gt;var filteredparts = [];&lt;BR /&gt;for (var i in parts) {&lt;BR /&gt;var value = parts[i];&lt;BR /&gt;&lt;BR /&gt;// Add '#' before LV_APT if it's not null or empty&lt;BR /&gt;if (i == 4 &amp;amp;&amp;amp; !IsNullOrEmpty(value)) {&lt;BR /&gt;value = "#" + value;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if (IsNullOrEmpty(value)) continue;&lt;BR /&gt;Push(filteredparts, value); // Use Push to add elements&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Concatenate with a space&lt;BR /&gt;var finaladdress = Concatenate(filteredparts, " ");&lt;BR /&gt;return finaladdress;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 19:10:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1528941#M1555</guid>
      <dc:creator>EricBregant2</dc:creator>
      <dc:date>2024-08-28T19:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1529043#M1556</link>
      <description>&lt;P&gt;It is best sharing code, add is as a code sample.&amp;nbsp; For arcade, I pick Javascript.&amp;nbsp; It is much easier to read, it maintains formatting, etc.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var lv_apt = $feature.LV_APT;
if (!IsEmpty(lv_apt)){
  lv_apt = `#${lv_apt}`
}
parts = [$feature.ST_NUM, $feature.DIRPRE, $feature.FEANME, $feature.FEATYP, lv_apt];

return function not_empty(x) {
  return !IsEmpty(x);
}
return Concatenate(Filter(parts, not_empty), ' ');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 21:09:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1529043#M1556</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-08-28T21:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule arcade statement</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1533534#M1558</link>
      <description>&lt;P&gt;Here is how we did it, our two direction fields, unit, and addNum_suf fields may or may not be Null.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;//Array to hold values and an index
var i = 0;
var features = [];

//Add value to array if not empty
function addvalue(feat) {
    if (!IsEmpty(feat)) {
        features[i++] = feat;
    }
}

//Add your values
addvalue($feature.Add_Number);
addvalue($feature.AddNum_Suf);
addvalue($feature.St_PreDir);
addvalue($feature.St_Name);
addvalue($feature.St_PosType);
addvalue($feature.St_PosDir);
addvalue($feature.Unit);

//Return a concatenated string with a space between each attribute
return Concatenate(features, " ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 18:43:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-arcade-statement/m-p/1533534#M1558</guid>
      <dc:creator>LindseyStone</dc:creator>
      <dc:date>2024-08-30T18:43:17Z</dc:date>
    </item>
  </channel>
</rss>

