<?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: How to create an expression that returns count of fields with a greater than 0 value? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1059790#M40177</link>
    <description>&lt;LI-CODE lang="javascript"&gt;var index = 0
if($feature["field_1"] &amp;gt; 0) { index += 1 }
if($feature["field_2"] &amp;gt; 0) { index += 1 }
return index

// if the fields can be null:
if(!IsEmpty($feature["field_1"]) &amp;amp;&amp;amp; $feature["field_1"] &amp;gt; 0) { index += 1 }&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 20 May 2021 05:59:17 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-05-20T05:59:17Z</dc:date>
    <item>
      <title>How to create an expression that returns count of fields with a greater than 0 value?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1059766#M40175</link>
      <description>&lt;P&gt;I want to use Arcade to create a pop-up expression field that is a count of some other fields in the dataset that have a non-zero value. For example:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="14.285714285714286%"&gt;field_1&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;field_2&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;field_3&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;field_4&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;field_5&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;field_6&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;&lt;STRONG&gt;custom_field&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="14.285714285714286%"&gt;0&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;0&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;4&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;4&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;0&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;1&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="14.285714285714286%"&gt;1&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;1&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;2&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;4&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;0&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;4&lt;/TD&gt;&lt;TD width="14.285714285714286%"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be similar to what the &lt;A href="https://support.microsoft.com/en-us/office/countif-function-e0de10c6-f885-4e71-abb4-1f464816df34" target="_blank" rel="noopener"&gt;COUNTIF function&lt;/A&gt; does in excel.&lt;/P&gt;&lt;P&gt;I have a small amount of experience in Arcade, and played around with incrementing a variable based on the result of an IIF statement:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var index = 0

iif($feature["field_1"]&amp;gt;=1, ++index, 0);

iif($feature["field_2"]&amp;gt;=1, ++index, 0);

return index&lt;/LI-CODE&gt;&lt;P&gt;This just ends up giving a value equal to the number of IIF statement in the code, regardless of whether they evaluate to true or false. I have also tried other variations on this, but no luck.&amp;nbsp;I am assuming that the trueValue of an IIF statement can't be used to increment a variable. This would make sense as the expression evaluations are treated as returns.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 20 May 2021 02:57:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1059766#M40175</guid>
      <dc:creator>JamesPreston1</dc:creator>
      <dc:date>2021-05-20T02:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an expression that returns count of fields with a greater than 0 value?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1059790#M40177</link>
      <description>&lt;LI-CODE lang="javascript"&gt;var index = 0
if($feature["field_1"] &amp;gt; 0) { index += 1 }
if($feature["field_2"] &amp;gt; 0) { index += 1 }
return index

// if the fields can be null:
if(!IsEmpty($feature["field_1"]) &amp;amp;&amp;amp; $feature["field_1"] &amp;gt; 0) { index += 1 }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 May 2021 05:59:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1059790#M40177</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-05-20T05:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an expression that returns count of fields with a greater than 0 value?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1060807#M40219</link>
      <description>&lt;P&gt;It works! Thank you so much, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 May 2021 20:54:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-create-an-expression-that-returns-count-of/m-p/1060807#M40219</guid>
      <dc:creator>JamesPreston1</dc:creator>
      <dc:date>2021-05-23T20:54:58Z</dc:date>
    </item>
  </channel>
</rss>

