Select to view content in your preferred language

GrouBy Data Expression

1000
11
Jump to solution
03-04-2024 08:57 AM
Labels (1)
JanelleShank
Emerging Contributor

Good Afternoon, All!

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. 

JanelleShank_0-1709571392930.png

 

var fs = FeaturesetByPortalItem(Portal("https://bedfordplanning.maps.arcgis.com"), "78eb292ce436450b85dc249bd3069741", 0, ["Precinct_name", "Reg_voters"], false)
var out_dict = {
  fields: [
    {name: "Precinct_Name", type: "esriFieldTypeString"},
    {name: "Reg_voters", type: "esriFieldTypeString"}
  ],
  features: [],
  geometryType: ""
}
var maxvotes = GroupBy("out_dict", 'Precinct_Name', {name: 'Reg_voters', expression: 'Reg_Voters', statistic: "MAX"})
 
Thank you,
Janelle
0 Kudos
11 Replies
jcarlson
MVP Esteemed Contributor

GroupBy returns a FeatureSet, so return maxvotes should do it. What does your expression look like at this point?

- Josh Carlson
Kendall County GIS
0 Kudos
JanelleShank
Emerging Contributor

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.

 

Best,

Janelle

0 Kudos