0 Replies Latest reply on Apr 20, 2012 5:50 AM by mleahyesri-ca-esridist

    ArcGIS 10.1 - groupByFieldsForStatistics fields with null values

    mleahyesri-ca-esridist
      Hello all,

      I have another question related to the new statistics abilities when querying features through the REST API in 10.1.  It seems that if I use a field to group the resulting statistics values, and if any records in the feature layer or table contain null values in the specified field, I get a valid-looking response, but with an empty 'features' value.  When no values are null, here's an example of what the response looks like when I ask for the stats to be grouped by a column named "integer_attribute":

      {
       "displayFieldName": "",
       "fieldAliases": {
        "integer_attribute": "integer_attribute",
        "total": "total"
       },
       "fields": [
        {
         "name": "integer_attribute",
         "type": "esriFieldTypeOID",
         "alias": "integer_attribute"
        },
        {
         "name": "total",
         "type": "esriFieldTypeDouble",
         "alias": "total"
        }
       ],
       "features": [
        {
         "attributes": {
          "integer_attribute": 0,
          "total": 8659
         }
        },
        {
         "attributes": {
          "integer_attribute": 1,
          "total": 7639
         }
        }
       ]
      }


      However, if any of the records contain a null value for the "integer_attribute", I get the following response:

      {
       "displayFieldName": "",
       "fieldAliases": {
        "integer_attribute": "integer_attribute",
        "total": "total"
       },
       "fields": [
        {
         "name": "integer_attribute",
         "type": "esriFieldTypeOID",
         "alias": "integer_attribute"
        },
        {
         "name": "total",
         "type": "esriFieldTypeDouble",
         "alias": "total"
        }
       ],
       "features": [
       
       ]
      }


      Is this an outcome I should have expected?  I was hoping that the result would look more like the first response, but with a third entry that contains the count of records where the integer_attribute is null.  However, if this operation is not allowed when the group-by field contains null values, it would be helpful to get some kind of error that indicates what went wrong.

      If I add a where clause to the query that excludes null values, I'll get results again...so I can still get results for non-null records as long as I do that.  However, it would be helpful if I actually could get the total null values, because no data is also a valid type of information (i.e., it helps to reveal information that is not yet known or incomplete).  The only workaround I can think of is to request the total statistics (un-grouped) separately, then get the grouped stats for the non-null records...then I'd have to loop through the results and subtract the totals from the un-grouped total...with the remainder being the number of null results.  Can anyone suggest a better approach?