<?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: GrouBy Data Expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390598#M9209</link>
    <description>&lt;P&gt;Since your data is private, I can't test it. However, I was able to test using a public service and it worked as expected, returning two items in the table with the maximum value for each aggregationMethod&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs =  FeatureSetByPortalItem(
    Portal("https://www.arcgis.com"),
    // portal item id
    "7b1fb95ab77f40bf8aa09c8b59045449",
    0, // layer id
    ["*"], // fields to include
    false // include or exclude geometry
  );

GroupBy(fs, 'aggregationMethod', {name: 'TOTPOP_CY', expression: 'TOTPOP_CY', statistic: "MAX"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2024 18:13:30 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2024-03-04T18:13:30Z</dc:date>
    <item>
      <title>GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390517#M9200</link>
      <description>&lt;P&gt;Good Afternoon, All!&lt;/P&gt;&lt;P&gt;I have a dataset of voting results and I can trying to create a data expression that returns the MAX value of registered voters within each district and then add the total of each MAX value to find the total number of those registered. I have written a data expression using the GoupBy function, however, it is returning a null value. I have provided examples of my data expression and data below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JanelleShank_0-1709571392930.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96764iD6F72BFAE14BA03E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JanelleShank_0-1709571392930.png" alt="JanelleShank_0-1709571392930.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;fs&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;FeaturesetByPortalItem&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Portal&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://bedfordplanning.maps.arcgis.com" target="_blank"&gt;https://bedfordplanning.maps.arcgis.com&lt;/A&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;"78eb292ce436450b85dc249bd3069741"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;, [&lt;/SPAN&gt;&lt;SPAN&gt;"Precinct_name"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Reg_voters"&lt;/SPAN&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;SPAN&gt;false&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;out_dict&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;fields&lt;/SPAN&gt;&lt;SPAN&gt;: [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;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N&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"out_dict"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'Precinct_Name'&lt;/SPAN&gt;&lt;SPAN&gt;, {&lt;/SPAN&gt;&lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;'Reg_voters'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;expression&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;'Reg_Voters'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;statistic&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"MAX"&lt;/SPAN&gt;&lt;SPAN&gt;})&lt;/SPAN&gt;&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;&lt;SPAN&gt;Janelle&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 Mar 2024 16:57:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390517#M9200</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-04T16:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390526#M9201</link>
      <description>&lt;P&gt;You're using out_dict in the GroupBy, but you haven't assigned any records to it. Why aren't you using fs in the GroupBy?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:13:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390526#M9201</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-03-04T17:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390527#M9202</link>
      <description>&lt;P&gt;I thought by using "out_dict", I was assigning a new variable.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:14:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390527#M9202</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-04T17:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390533#M9203</link>
      <description>&lt;P&gt;The first parameter of the GroupBy function is the FeatureSet that contains the data, which should be fs. The out_dict variable is just an empty FeatureSet you've created.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:22:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390533#M9203</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-03-04T17:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390540#M9204</link>
      <description>&lt;P&gt;Thank you, I'll give that try.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:27:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390540#M9204</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-04T17:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390548#M9205</link>
      <description>&lt;P&gt;When I replaced "out_dict" with fs, I got an error that it could not execute the expression. Do you happen to have any idea of where I am going wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 16:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390548#M9205</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-07T16:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390568#M9206</link>
      <description>&lt;P&gt;When using variables, don't encase them in quotes.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var maxvotes = GroupBy(fs, 'Precinct_Name', {name: 'Reg_voters', expression: 'Reg_Voters', statistic: "MAX"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:41:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390568#M9206</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-03-04T17:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390573#M9207</link>
      <description>&lt;P&gt;Thank you. I removed the quotes from the variable and the expression was able to run this time. However it returned a "null" value when it should return a table, like the one below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JanelleShank_0-1709574418615.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/96777iCFE2EEEFE2E3F0E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JanelleShank_0-1709574418615.png" alt="JanelleShank_0-1709574418615.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do I need to return to the empty FeatureSet?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 17:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390573#M9207</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-04T17:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390598#M9209</link>
      <description>&lt;P&gt;Since your data is private, I can't test it. However, I was able to test using a public service and it worked as expected, returning two items in the table with the maximum value for each aggregationMethod&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs =  FeatureSetByPortalItem(
    Portal("https://www.arcgis.com"),
    // portal item id
    "7b1fb95ab77f40bf8aa09c8b59045449",
    0, // layer id
    ["*"], // fields to include
    false // include or exclude geometry
  );

GroupBy(fs, 'aggregationMethod', {name: 'TOTPOP_CY', expression: 'TOTPOP_CY', statistic: "MAX"})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 18:13:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390598#M9209</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-03-04T18:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390607#M9210</link>
      <description>&lt;P&gt;GroupBy returns a FeatureSet, so &lt;STRONG&gt;return maxvotes &lt;/STRONG&gt;should do it. What does your expression look like at this point?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 18:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1390607#M9210</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-03-04T18:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1392634#M9241</link>
      <description>&lt;P&gt;Thank you for your help on this! Your code helped me refine my expression and I also noticed that I had my Item number incorrect in my expression and once that was fixed I was able to apply the correct expression.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Janelle&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 16:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1392634#M9241</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-07T16:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: GrouBy Data Expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1392636#M9242</link>
      <description>&lt;P&gt;Thank you for your help. My expression is the same as above. Turns out it was not working correctly because I had the ID number wrong for my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Janelle&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2024 16:30:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/grouby-data-expression/m-p/1392636#M9242</guid>
      <dc:creator>JanelleShank</dc:creator>
      <dc:date>2024-03-07T16:30:44Z</dc:date>
    </item>
  </channel>
</rss>

