<?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 Rounding records pulled from related table? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/rounding-records-pulled-from-related-table/m-p/1195528#M47101</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the FeatureSetByRelationshipName to pull related table records into a popup. One of the fields (SumOfReturnMG) being pulled is an integer field and I need to round the number to 2 decimals. What would be be best way to format the field within my existing Arcade expression?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression user below&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;var fs = FeatureSetByRelationshipName($feature,"qry_HUC_USEGROUP_RET" , ['*'], false);&lt;BR /&gt;var result = "";&lt;BR /&gt;var cnt = Count(fs);&lt;BR /&gt;if (cnt &amp;gt; 0) {&lt;BR /&gt;// start loop through related records&lt;BR /&gt;for (var f in fs) {&lt;BR /&gt;// for each f (=feature) in related features, add attendee to the result&lt;BR /&gt;result += TextFormatting.NewLine + f.YearNumber + TextFormatting.NewLine + f.SumOfReturnMG;&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;// overwrite result with text to indicate that there are no attendees&lt;BR /&gt;result = "";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return result;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Resulting record (field highlighted in blue)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DaveK_0-1658773174239.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46697i636DBB268E2B6681/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DaveK_0-1658773174239.png" alt="DaveK_0-1658773174239.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jul 2022 18:21:03 GMT</pubDate>
    <dc:creator>DaveK</dc:creator>
    <dc:date>2022-07-25T18:21:03Z</dc:date>
    <item>
      <title>Rounding records pulled from related table?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/rounding-records-pulled-from-related-table/m-p/1195528#M47101</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the FeatureSetByRelationshipName to pull related table records into a popup. One of the fields (SumOfReturnMG) being pulled is an integer field and I need to round the number to 2 decimals. What would be be best way to format the field within my existing Arcade expression?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression user below&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;var fs = FeatureSetByRelationshipName($feature,"qry_HUC_USEGROUP_RET" , ['*'], false);&lt;BR /&gt;var result = "";&lt;BR /&gt;var cnt = Count(fs);&lt;BR /&gt;if (cnt &amp;gt; 0) {&lt;BR /&gt;// start loop through related records&lt;BR /&gt;for (var f in fs) {&lt;BR /&gt;// for each f (=feature) in related features, add attendee to the result&lt;BR /&gt;result += TextFormatting.NewLine + f.YearNumber + TextFormatting.NewLine + f.SumOfReturnMG;&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;// overwrite result with text to indicate that there are no attendees&lt;BR /&gt;result = "";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return result;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Resulting record (field highlighted in blue)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DaveK_0-1658773174239.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46697i636DBB268E2B6681/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DaveK_0-1658773174239.png" alt="DaveK_0-1658773174239.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 18:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/rounding-records-pulled-from-related-table/m-p/1195528#M47101</guid>
      <dc:creator>DaveK</dc:creator>
      <dc:date>2022-07-25T18:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding records pulled from related table?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/rounding-records-pulled-from-related-table/m-p/1195759#M47111</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/math_functions/#round" target="_blank" rel="noopener"&gt;You can use the Round() function.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Other stuff:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;it's better to just load the fields you need to use less bandwidth, especially for large datasets&lt;/LI&gt;&lt;LI&gt;if you fill an array and concatenate it, you won't have the empty first line&lt;/LI&gt;&lt;LI&gt;if you restructure a bit, you can get rid of the nested code blocks&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByRelationshipName($feature,"qry_HUC_USEGROUP_RET" , ["YearNumber", "SumOfReturnMG"], false);
var result = []; //array
// start loop through related records
for (var f in fs) {
// for each f (=feature) in related features, add attendee to the result
    Push(result, f.YearNumber + TextFormatting.NewLine + Round(f.SumOfReturnMG, 2);
}
// if result is empty, return a default value, else return the concatenated array
return IIF(Count(result) == 0, "", Concatenate(result, TextFormatting.NewLine))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 07:29:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/rounding-records-pulled-from-related-table/m-p/1195759#M47111</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-07-26T07:29:05Z</dc:date>
    </item>
  </channel>
</rss>

