Select to view content in your preferred language

Make a feature count for each of the username

677
3
Jump to solution
03-30-2017 08:19 AM
by Anonymous User
Not applicable

Hi all,

I am trying to get a feature count per user names. I have an array of unique user names that I want to loop through and produce as series of counts/users. How would I achieve this?

Thanks,

Alex

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Nervermind. I got it. This query set up solved it for me.

Thanks,

Alex

 var queryloop = new Query();
                var queryTaskloop = new QueryTask("http://services.arcgis.com/UHg8l1wC48WQyDSO/arcgis/rest/services/U64gI/FeatureServer/0");
                arrayUtil.forEach(unique, function (feature) {
                    console.log(feature)
                    queryloop.where = "f3 = " + "'" + feature + "'";  
                    queryloop.returnGeometry = false;
                    queryloop.outFields = ["*"];
                    queryTaskloop.execute(queryloop, queryCallbacksum);
                });

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

??? What does feature count and username have in common? You need to explain way better.

0 Kudos
by Anonymous User
Not applicable

Sorry,

Lest say I have 10 users. Each one of their appI want to count how many times they appear in my table. Kind of a summary.

username:          count:

John F.                 68

Peter A.                189

Julie F.                 92

Mark A.                178

Julius F.                550

.

.....

In my table I have a count field that I calculated to 1 so I can sum up the users like this:

 function queryCallbacksum(featureSet) {
                    var features = featureSet.features;
                    sum = 0;
                    arrayUtil.forEach(features, function (feature) {
                        sum += feature.attributes.CountField;
                    });
                    console.log(sum)
                   
                }

I am trying to set a loop that would produce a count per users like this :


//My  array made of unique names
unique = arraynames.filter(function(itm, i, a) {
                return i == arraynames.indexOf(itm);
                });

//My create queries loop
                arrayUtil.forEach(unique, function (feature) {
                    var queryloop = new Query();
                    var queryTaskloop = new QueryTask("http://services.arcgis.com/UHg8l1wC48WQyDSO/arcgis/rest/services/U64gI/FeatureServer/0");
                    queryloop.where = "f3 =" + feature;  
                    queryloop.returnGeometry = false;
                    queryloop.outFields = ["CountField"];
                    queryTaskloop.execute(queryloop, queryCallbacksum);
                });
0 Kudos
by Anonymous User
Not applicable

Nervermind. I got it. This query set up solved it for me.

Thanks,

Alex

 var queryloop = new Query();
                var queryTaskloop = new QueryTask("http://services.arcgis.com/UHg8l1wC48WQyDSO/arcgis/rest/services/U64gI/FeatureServer/0");
                arrayUtil.forEach(unique, function (feature) {
                    console.log(feature)
                    queryloop.where = "f3 = " + "'" + feature + "'";  
                    queryloop.returnGeometry = false;
                    queryloop.outFields = ["*"];
                    queryTaskloop.execute(queryloop, queryCallbacksum);
                });
0 Kudos