GroupBy on Query

600
1
01-17-2019 10:02 AM
EvelynHernandez
Occasional Contributor III

Hello there,

Is there any example on how to use group by in a query for arcgis js api?

I dont see any example on how to do this.

Thanks in advice!

Tags (1)
0 Kudos
1 Reply
EvelynHernandez
Occasional Contributor III

I have this that I have made by myself but it doesnt work, i got an error.

What am i missing?

 var qTask = new QueryTask(layers.read_repartos(token));
 
 var q = new Query();
 
 var statisticDefinition = new StatisticDefinition();
 statisticDefinition.statisticType = "count";
 statisticDefinition.onStatisticField = "created_date";
 
 q.where = "created_user= 'vialactea\\czeballo'";
 q.outFields=["*"];


 q.outStatistics = [statisticDefinition];


 qTask.execute(q, (featureSet) => {
 console.log(featureSet)
 var us = featureSet.features.map(u=>{
 var ob = {
 key: u.attributes.created_user,
 text: u.attributes.created_user,
 value:u.attributes.created_user,
 content:u.attributes.created_user
 }
 return ob;
 });


 
 return resolve(us);
 }, (error) => {
 console.log(error)
 });
0 Kudos