I have built a widget in WebAppBuilder for ArcGis where you can select an area and see the information that is within it, the selection is based on the radius you choose, in this case between 100 and 300 metres.
I'd like to add a functionality so I would like to create from the first query result the sum of the four fields into the attribute table.
I found out on the API the Statitics Definition class so I used with the result from the first query but it is not working.
I'd appreciate if someone could give some advice about the sum query.
Thanks in advace.
Below the code :
var myQuery = new Query();
myQuery.where = "1 = 1";
myQuery.outFields = ["POB_TOT", "EDAD0015", "EDAD1664","EDAD65_"];
myQuery.returnGeometry = true;
var myQueryTask = new QueryTask(_poblacion);
myQuery.geometry = circle;
myQuery.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
var sumfields = new StatisticDefinition();
sumfields.statisticType = "sum";
sumfields.onStatisticField = "POB_TOT", "EDAD0015", "EDAD1664","EDAD65_";
myQuery.outStatistics = sumfields;