<?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: Pop-up Arcade expression to count how many defects which match the inventory data in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285147#M51881</link>
    <description>&lt;P&gt;Amazing Johannes, it's worked perfectly! Thank you so much for your help&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 14:07:37 GMT</pubDate>
    <dc:creator>cat206</dc:creator>
    <dc:date>2023-05-03T14:07:37Z</dc:date>
    <item>
      <title>Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1284750#M51849</link>
      <description>&lt;P&gt;Hi, I'm looking for help with Arcade. I have a polyline feature class of asset inventory (roads - one line for each lane, so dual carriageways will have 2 lines running paralell) and a defect feature class as points. Unfortunately the defect spatial accuracy is not great and therefore i'm unable to use the buffer and intersect function.&lt;/P&gt;&lt;P&gt;I am wondering if I can create a pop-up expression which counts the number of defects that match attributes within the roads inventory layer. Both layers have the unique ID field and Lane number. The road inventory has a total length, and the defect has a number of how far down the road section the defect is present, see examples below:&lt;/P&gt;&lt;P&gt;Road inventory:&lt;/P&gt;&lt;P&gt;UniqueID = abc1&lt;/P&gt;&lt;P&gt;LaneID = L1&lt;/P&gt;&lt;P&gt;Start length = 100&lt;/P&gt;&lt;P&gt;End length = 900&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Defect Data:&lt;/P&gt;&lt;P&gt;UniqueID = abc1&lt;/P&gt;&lt;P&gt;LaneID = L1&lt;/P&gt;&lt;P&gt;Defect Meterage Location = 450&lt;/P&gt;&lt;P&gt;I would like to create a pop-up expression when i click on the road inventory layer, it can count how many defects 'fall' within the road section, by matching the attributes (UniqueID and LaneID fields), and also when there Defect Meterage location is located within the road inventory length, like this for example&amp;nbsp;Defect Meterage Location (450m) is between the start and end field (StartField &amp;gt;='100' And EndField &amp;lt;='900')&lt;/P&gt;&lt;P&gt;Is this at all possible? If so, does anyone have any idea where to start / which function i need to use. Any help would be much appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:09:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1284750#M51849</guid>
      <dc:creator>cat206</dc:creator>
      <dc:date>2023-05-02T15:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1284761#M51850</link>
      <description>&lt;LI-CODE lang="javascript"&gt;// Popup Arcade expression for the Road Inventory layer

// load the Defects layer
var defects = FeaturesetByName($datastore, "Defects", ["*"], false)

// filter the defects by UniqueID, LaneID, and Meterage
var unique_id = $feature.UniqueID
var lane_id = $feature.LaneID
var start = $feature.StartLength
var end = $feature.EndLength
var query = "UniqueID = @unique_id AND LaneID = @lane_id AND Meterage &amp;gt;= @start AND Meterage &amp;lt;= @end"
var filtered_defects = Filter(defects, query)

// create and return the text output
var return_lines = [
    Count(filtered_defects) + " defects on this lane.",
    ]
for(var d in filtered_defects) {
    Push(return_lines, "Defect at " + d.Meterage + " meters")
}
return Concatenate(return_lines, Textformatting.NewLine)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 02 May 2023 15:40:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1284761#M51850</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-02T15:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285147#M51881</link>
      <description>&lt;P&gt;Amazing Johannes, it's worked perfectly! Thank you so much for your help&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 14:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285147#M51881</guid>
      <dc:creator>cat206</dc:creator>
      <dc:date>2023-05-03T14:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285598#M51928</link>
      <description>&lt;P&gt;Hi Johannes, sorry another question. I've been asked to try nd symbolise the road inventory but the defect count number, so I thought about trying to run the above script in a new field and using the field calculation option, taking away the Push function element of the above code but it doesn't like it at all.&lt;BR /&gt;&lt;BR /&gt;I get an error message at line 17 which falls on the&amp;nbsp;&lt;STRONG&gt;var filtered_defects = Filter(defects, query)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've tried this:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;// load the Defects layer&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;defects&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$datastore&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Defects"&lt;/SPAN&gt;&lt;SPAN&gt;, [&lt;/SPAN&gt;&lt;SPAN&gt;"*"&lt;/SPAN&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// filter the defects by UniqueID, LaneID, and Meterage&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;unique_id&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;sect_label&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;lane_id&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;xsp_code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;start&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;s_chainage&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;end&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;e_chainage&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;query&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"UniqueID = @unique_id AND Lane = @lane_id AND Meterage &amp;gt;= @start AND Meterage &amp;lt;= @end"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;filtered_defects&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Filter&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;defects&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;query&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// create and return the text output&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;return_lines&lt;/SPAN&gt;&lt;SPAN&gt; = [&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;filtered_defects&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;return&amp;nbsp;&lt;SPAN&gt;return_lines&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 04 May 2023 12:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285598#M51928</guid>
      <dc:creator>cat206</dc:creator>
      <dc:date>2023-05-04T12:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285909#M51952</link>
      <description>&lt;P&gt;Calculate Field expects you to return a single value, but you return an Array (the square brackets), which is a collection of multiple values. (Popup expressions&amp;nbsp; also expect a single return value, I get that by using the Concatenate function)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You just have to return the count:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var filtered_defects = Filter(defects, query)
return Count(filtered_defects)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 May 2023 21:34:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1285909#M51952</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-04T21:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Pop-up Arcade expression to count how many defects which match the inventory data</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1286082#M51962</link>
      <description>&lt;P&gt;I did try that but get the same error message on line 17. Not sure what the issue is but i'll keep trying&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cat206_0-1683293117865.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69944i1243468267A4E900/image-size/medium?v=v2&amp;amp;px=400" role="button" title="cat206_0-1683293117865.png" alt="cat206_0-1683293117865.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 13:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/pop-up-arcade-expression-to-count-how-many-defects/m-p/1286082#M51962</guid>
      <dc:creator>cat206</dc:creator>
      <dc:date>2023-05-05T13:25:55Z</dc:date>
    </item>
  </channel>
</rss>

