<?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: Count function in Arcade Not working properly in Field Maps, always returns 1. in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304487#M53159</link>
    <description>&lt;P&gt;You're counting the number of records in the FeatureSet "subset". You need to get the attribute from that featureset and count the number of characters in it.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var block = FeatureSetByName($map, "Blocks")
var recordGUID = upper($feature.BlockGuid)
var subset = First(Filter(block, `GlobalID = '${recordGUID}'`));
if (!IsEmpty(subset) {
    if (Count(subset.Block) == 1) {
      return Concatenate(["0", subset.Block])
    }
    else {
      return subset.Block
    }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 29 Jun 2023 15:08:29 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-06-29T15:08:29Z</dc:date>
    <item>
      <title>Count function in Arcade Not working properly in Field Maps, always returns 1.</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304466#M53157</link>
      <description>&lt;P&gt;I'm working on smart forms for a Field Maps map. There's an attribute called Block in a polygon layer, and it's a text string so that there can leading zeros for blocks 1-9. When someone adds a point inside the block, I want the Block number to auto-fill in the point attributes. I can get other attributes to auto-fill just fine. But for this, trying to use Count to know whether it is a single character or not, seems to not be working. It always adds a leading zero, no matter the number (e.g. 014, or 004 if the leading zero was already there). Looking for help on why the Count is not correctly counting the text characters.&lt;/P&gt;&lt;P&gt;First code attempt:&lt;/P&gt;&lt;P&gt;var block = FeatureSetByName($map, "Blocks")&lt;BR /&gt;var recordGUID = upper($feature.BlockGuid)&lt;BR /&gt;var subset = filter(block, `GlobalID = '${recordGUID}'`);&lt;BR /&gt;if (Count(subset) &amp;gt; 0) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (Count(subset) == 1) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return Concatenate(["0", First(subset).Block])&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return First(subset).Block&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Second code attempt:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;block&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;$map&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Blocks"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;recordGUID&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;upper&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;BlockGuid&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;subset&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;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N&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;First&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;subset&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;Block&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Jun 2023 14:20:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304466#M53157</guid>
      <dc:creator>JohnSmoluk</dc:creator>
      <dc:date>2023-06-29T14:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count function in Arcade Not working properly in Field Maps, always returns 1.</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304487#M53159</link>
      <description>&lt;P&gt;You're counting the number of records in the FeatureSet "subset". You need to get the attribute from that featureset and count the number of characters in it.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var block = FeatureSetByName($map, "Blocks")
var recordGUID = upper($feature.BlockGuid)
var subset = First(Filter(block, `GlobalID = '${recordGUID}'`));
if (!IsEmpty(subset) {
    if (Count(subset.Block) == 1) {
      return Concatenate(["0", subset.Block])
    }
    else {
      return subset.Block
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:08:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304487#M53159</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-06-29T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Count function in Arcade Not working properly in Field Maps, always returns 1.</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304512#M53160</link>
      <description>&lt;P&gt;Aha! OK, I see what I did wrong there. Thank you very much, that worked!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 16:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/count-function-in-arcade-not-working-properly-in/m-p/1304512#M53160</guid>
      <dc:creator>JohnSmoluk</dc:creator>
      <dc:date>2023-06-29T16:00:26Z</dc:date>
    </item>
  </channel>
</rss>

