<?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 Data expression to count attributes across multiple fields using GroupBy in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-count-attributes-across/m-p/1391932#M9221</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm relatively new to arcade and have ran into a wall. I've got a layer that has multiple fields named AccessoryStructure1, AccessoryStructure2 and so on all the way to AccessoryStructure10. Each of these fields can then have an attribute from a domain that each field shares. For example a feature in this layer could look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_0-1709740099458.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97078i5F12703EFC737EDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="JacobMcDermott_0-1709740099458.png" alt="JacobMcDermott_0-1709740099458.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The attributes with a letter and number represent a physical structure such as a shed or deck, and 0 means none. What I need to do is get a count of all the various types of structures in the layer so a total of sheds, decks and so on, and then get a count of all the structures combined. My plan was to use the groupby function to pull out each type of structure and count them, set that to a variable, and then create one more variable that is the sum of all the previous variables.&lt;/P&gt;&lt;P&gt;Unfortunately, I'm unable to get the groupby function to work and keep running into errors. Here is my code so far.&lt;/P&gt;&lt;P&gt;var p = Portal('myportalurl')&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(p,'myitem#','7',["AccessoryStructure1",&lt;BR /&gt;"AccessoryStructure2","AccessoryStructure3","AccessoryStructure4",&lt;BR /&gt;"AccessoryStructure5","AccessoryStructure6","AccessoryStructure7",&lt;BR /&gt;"AccessoryStructure8","AccessoryStructure9",&lt;BR /&gt;"AccessoryStructure10"], false);&lt;/P&gt;&lt;P&gt;var Shed = GroupBy(&lt;BR /&gt;fs,&lt;BR /&gt;{name: 'AccessoryStructure', expression: 'Shed'},&lt;BR /&gt;[&lt;BR /&gt;{name: 'AccessoryStructure1', expression: "case when AccessoryStructure1 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure2', expression: "case when AccessoryStructure2 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure3', expression: "case when AccessoryStructure3 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure4', expression: "case when AccessoryStructure4 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure5', expression: "case when AccessoryStructure5 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure6', expression: "case when AccessoryStructure6 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure7', expression: "case when AccessoryStructure7 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure8', expression: "case when AccessoryStructure8 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure9', expression: "case when AccessoryStructure9 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure10', expression: "case when AccessoryStructure10 = 'S100' then 1 else 0", statistic: 'SUM'}&lt;BR /&gt;]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;return Shed&lt;/P&gt;&lt;P&gt;I then get this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_1-1709741206254.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97084i8F2C2322B3569558/image-size/large?v=v2&amp;amp;px=999" role="button" title="JacobMcDermott_1-1709741206254.png" alt="JacobMcDermott_1-1709741206254.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I should note that while these values are part of a domain they are the actual code and not the description (so the actual string of text that goes into the attribute field) Not sure if that makes a difference or not but wanted to put that out there.&lt;/P&gt;&lt;P&gt;Here is the domain table if it's helpful to know&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_2-1709741504637.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97085iFD15A95095D4D880/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JacobMcDermott_2-1709741504637.png" alt="JacobMcDermott_2-1709741504637.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any help getting me unstuck is appreciated!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2024 16:17:41 GMT</pubDate>
    <dc:creator>JacobMcDermott</dc:creator>
    <dc:date>2024-03-06T16:17:41Z</dc:date>
    <item>
      <title>Data expression to count attributes across multiple fields using GroupBy</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-count-attributes-across/m-p/1391932#M9221</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm relatively new to arcade and have ran into a wall. I've got a layer that has multiple fields named AccessoryStructure1, AccessoryStructure2 and so on all the way to AccessoryStructure10. Each of these fields can then have an attribute from a domain that each field shares. For example a feature in this layer could look something like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_0-1709740099458.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97078i5F12703EFC737EDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="JacobMcDermott_0-1709740099458.png" alt="JacobMcDermott_0-1709740099458.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The attributes with a letter and number represent a physical structure such as a shed or deck, and 0 means none. What I need to do is get a count of all the various types of structures in the layer so a total of sheds, decks and so on, and then get a count of all the structures combined. My plan was to use the groupby function to pull out each type of structure and count them, set that to a variable, and then create one more variable that is the sum of all the previous variables.&lt;/P&gt;&lt;P&gt;Unfortunately, I'm unable to get the groupby function to work and keep running into errors. Here is my code so far.&lt;/P&gt;&lt;P&gt;var p = Portal('myportalurl')&lt;/P&gt;&lt;P&gt;var fs = FeatureSetByPortalItem(p,'myitem#','7',["AccessoryStructure1",&lt;BR /&gt;"AccessoryStructure2","AccessoryStructure3","AccessoryStructure4",&lt;BR /&gt;"AccessoryStructure5","AccessoryStructure6","AccessoryStructure7",&lt;BR /&gt;"AccessoryStructure8","AccessoryStructure9",&lt;BR /&gt;"AccessoryStructure10"], false);&lt;/P&gt;&lt;P&gt;var Shed = GroupBy(&lt;BR /&gt;fs,&lt;BR /&gt;{name: 'AccessoryStructure', expression: 'Shed'},&lt;BR /&gt;[&lt;BR /&gt;{name: 'AccessoryStructure1', expression: "case when AccessoryStructure1 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure2', expression: "case when AccessoryStructure2 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure3', expression: "case when AccessoryStructure3 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure4', expression: "case when AccessoryStructure4 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure5', expression: "case when AccessoryStructure5 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure6', expression: "case when AccessoryStructure6 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure7', expression: "case when AccessoryStructure7 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure8', expression: "case when AccessoryStructure8 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure9', expression: "case when AccessoryStructure9 = 'S100' then 1 else 0", statistic: 'SUM'},&lt;BR /&gt;{name: 'AccessoryStructure10', expression: "case when AccessoryStructure10 = 'S100' then 1 else 0", statistic: 'SUM'}&lt;BR /&gt;]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;return Shed&lt;/P&gt;&lt;P&gt;I then get this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_1-1709741206254.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97084i8F2C2322B3569558/image-size/large?v=v2&amp;amp;px=999" role="button" title="JacobMcDermott_1-1709741206254.png" alt="JacobMcDermott_1-1709741206254.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I should note that while these values are part of a domain they are the actual code and not the description (so the actual string of text that goes into the attribute field) Not sure if that makes a difference or not but wanted to put that out there.&lt;/P&gt;&lt;P&gt;Here is the domain table if it's helpful to know&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacobMcDermott_2-1709741504637.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/97085iFD15A95095D4D880/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JacobMcDermott_2-1709741504637.png" alt="JacobMcDermott_2-1709741504637.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any help getting me unstuck is appreciated!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 16:17:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/data-expression-to-count-attributes-across/m-p/1391932#M9221</guid>
      <dc:creator>JacobMcDermott</dc:creator>
      <dc:date>2024-03-06T16:17:41Z</dc:date>
    </item>
  </channel>
</rss>

