<?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's Round function giving inconsistent results in AGOL pop-up in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-s-round-function-giving-inconsistent/m-p/1006404#M37587</link>
    <description>&lt;P&gt;I just made a very similar arcade expression and noticed the same behavior that you're describing.&amp;nbsp; I decided to try rearranging the expression to multiply it by 100 before rounding, so that it looks more like the following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;round(travelpercent*100, 2) + '%'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to be giving me more consistent results now, though I don't have a lot of features to test it on.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT&lt;/P&gt;&lt;P&gt;I read the documentation for the Round function, and it has a note that says to use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#text" target="_blank" rel="noopener"&gt;Text function&lt;/A&gt; to format numbers for display in labels and pop-ups.&amp;nbsp; After looking at the documentation, I altered my expression to include the text function instead, and it even multiplies by 100 for me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Text(travelpercent, '#.##%')&lt;/LI-CODE&gt;&lt;P&gt;If you don't want decimals for your percentage, you will probably want to use the following format:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Text(travelpercent, '#%')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 00:30:46 GMT</pubDate>
    <dc:creator>DeniseBeckham</dc:creator>
    <dc:date>2020-12-03T00:30:46Z</dc:date>
    <item>
      <title>Arcade's Round function giving inconsistent results in AGOL pop-up</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-s-round-function-giving-inconsistent/m-p/484595#M24310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've pulled the Unacast web service into an AGOL web map for our coronavirus site. For part of the display in my pop-up, I have this custom Arcade expression to convert the values in the difference field to a positive number and then display the percentages with a max of two decimals:&lt;/P&gt;&lt;P&gt;&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; travelpercent &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Abs&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$feature&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"daily_distance_diff"&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;return&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;round&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;travelpercent&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;100&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string 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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the results in my pop-ups are inconsistent. In one spot, it looks great:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="488385" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/488385_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;But in another, it looks like this:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="488386" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/488386_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been ignoring it so far, but Douglas County is my county and that percentage looks ridiculous. Are there any tweaks I can make to the Arcade code to fix this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited to add: I tried changing the rounding to 1 decimal place and it rounded our county up to 60%. Then I tried 0 and it rounded to 100%!! Oh my.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:22:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-s-round-function-giving-inconsistent/m-p/484595#M24310</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2021-12-11T21:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade's Round function giving inconsistent results in AGOL pop-up</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-s-round-function-giving-inconsistent/m-p/1006404#M37587</link>
      <description>&lt;P&gt;I just made a very similar arcade expression and noticed the same behavior that you're describing.&amp;nbsp; I decided to try rearranging the expression to multiply it by 100 before rounding, so that it looks more like the following.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;round(travelpercent*100, 2) + '%'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to be giving me more consistent results now, though I don't have a lot of features to test it on.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT&lt;/P&gt;&lt;P&gt;I read the documentation for the Round function, and it has a note that says to use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#text" target="_blank" rel="noopener"&gt;Text function&lt;/A&gt; to format numbers for display in labels and pop-ups.&amp;nbsp; After looking at the documentation, I altered my expression to include the text function instead, and it even multiplies by 100 for me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Text(travelpercent, '#.##%')&lt;/LI-CODE&gt;&lt;P&gt;If you don't want decimals for your percentage, you will probably want to use the following format:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Text(travelpercent, '#%')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 00:30:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-s-round-function-giving-inconsistent/m-p/1006404#M37587</guid>
      <dc:creator>DeniseBeckham</dc:creator>
      <dc:date>2020-12-03T00:30:46Z</dc:date>
    </item>
  </channel>
</rss>

