<?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 Not Getting Sum of values from loop expression in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288615#M14403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/4535"&gt;James Faron&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had problems in the past depending on the browser and one time it was an update issue of Chrome that prevented the code to work.&amp;nbsp;Glad to hear that your is working, that is the most important part!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jul 2019 15:57:30 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2019-07-10T15:57:30Z</dc:date>
    <item>
      <title>Arcade Popup Not Getting Sum of values from loop expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288612#M14400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am implementing a custom expression which gets the result,&amp;nbsp;a sum where applicable (i.e.when there are more than one results). The expression tests successfully in the expression editor, but the popup only returns the first result, i.e. does not get the sum of multiple results. The following expression yields a result of 24&amp;nbsp;when Test is clicked in the Expression editor, but the popup yields only the first of the three (in this case) results, the number 8 in this&amp;nbsp; case (three results with the value of 8 each). Here is the code, followed by a screenshot of the test result, and then the popup on the map (the attribute in question is the last line (Total kW on Applications).&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var fc = FeatureSetById($map, /* PowerClerk Application Approved */ "DG_Transformer_Availability_Popup_test_2658")&lt;BR /&gt;var code = $feature["PARENT_ID"]&lt;BR /&gt;//var pizza = 26712474;&lt;BR /&gt;var sql = "TRANSFORMER_ID = " + code;&lt;BR /&gt;//var sql = "TRANSFORMER_ID = " + pizza;&lt;BR /&gt;//var sql = "TRANSFORMER_ID = 12157630"&lt;BR /&gt;Console(sql);&lt;BR /&gt;var applications = Filter(fc, sql);&lt;BR /&gt;var cnt = Count(applications);&lt;BR /&gt;Console(cnt);&lt;BR /&gt;var getAppKW;&lt;BR /&gt;var sumAppKW = 0;&lt;BR /&gt;if(cnt &amp;gt; 0){&lt;BR /&gt; Console(cnt);&lt;BR /&gt; for (var application in applications){&lt;BR /&gt; sumAppKW += application.APPLICATION_KW_AC &lt;BR /&gt; }&lt;BR /&gt; getAppKW = sumAppKW&lt;BR /&gt;}else{&lt;BR /&gt; getAppKW = "N/A"&lt;BR /&gt;}&lt;BR /&gt;if (IsEmpty(getAppKW) || (getAppKW == NULL)){&lt;BR /&gt; getAppKW = "No Data"&lt;BR /&gt;}&lt;BR /&gt;Console(getAppKW);&lt;BR /&gt;return getAppKW&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;IMG alt="Expression Test" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/452687_test.jpg" /&gt;&lt;IMG alt="Popup Result" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/452688_popup.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The line in the popup configuration (custom attribute display) is 'Total kW on Applications: {expression/expr5}', where expr5 is the expression quoted above.&amp;nbsp; This is on Portal for ArcGIS, 10.7.1.&amp;nbsp;It seems that the Popup does not wait for the loop to complete, or there is an error or flaw in the code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jim Faron&lt;/P&gt;&lt;P&gt;Unisource Energy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 23:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288612#M14400</guid>
      <dc:creator>JamesFaron</dc:creator>
      <dc:date>2019-07-09T23:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Popup Not Getting Sum of values from loop expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288613#M14401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/people/jfaron44" target="_blank"&gt;jfaron44&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing that I notice is that your are comparing your PARENT_ID to the TRANSFORMER_ID. Is that correct?Some minor adjustments to the code (however, this will not solve your problem):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;FeatureSetById&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"DG_Transformer_Availability_Popup_test_2658"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; code &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; $feature&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"PARENT_ID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TRANSFORMER_ID = "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; code&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; applications &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Filter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; cnt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;applications&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cnt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; getAppKW&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; sumAppKW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cnt &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; application &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; applications&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        sumAppKW &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; application&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;APPLICATION_KW_AC&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    getAppKW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sumAppKW&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    getAppKW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"N/A"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;getAppKW&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;getAppKW &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    getAppKW &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"No Data"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;getAppKW&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; getAppKW&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post back what your console is reporting?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288613#M14401</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T13:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Popup Not Getting Sum of values from loop expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288614#M14402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the response, and for your previous blog posts, they are very helpful. The PARENT_ID field data is equal to the TRANSFORMER_ID field in the related feature class.&lt;/P&gt;&lt;P&gt;I don't know if it's gremlins on the internet, or more likely a caching issue in the browser, but when I tried it this morning after reopening the application, it works as expected! I guess I'll do more developing in incognito window to eliminate that issue going forward, although I will also keep testing to see if there is any latency issue at work. The console was accurate, but the Popup was not, as described in my initial post, so it does seem pretty strange.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Jim Faron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2019 15:44:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288614#M14402</guid>
      <dc:creator>JamesFaron</dc:creator>
      <dc:date>2019-07-10T15:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Popup Not Getting Sum of values from loop expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288615#M14403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/4535"&gt;James Faron&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had problems in the past depending on the browser and one time it was an update issue of Chrome that prevented the code to work.&amp;nbsp;Glad to hear that your is working, that is the most important part!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2019 15:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-popup-not-getting-sum-of-values-from-loop/m-p/288615#M14403</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2019-07-10T15:57:30Z</dc:date>
    </item>
  </channel>
</rss>

