Statistical query group and sort
Query a feature table for statistics, grouping and sorting by different fields.
You can use statistical queries, grouping and sorting to process large amounts of data saved in feature tables. This is helpful for identifying trends and relationships within the data, which can be used to support further interpretations and decisions. For example, a health agency can use information on medical conditions occurring throughout a country to identify at-risk areas or demographics, and decide on further action and preventive measures.
The sample will start with some default options selected. You can immediately tap the "Get Statistics" button to see the results for these options. There are several ways to customize your queries:
- You can add statistic definitions to the top-left table using the combo boxes and "Add" button. Select a table row and tap "Remove" to remove a definition.
- To change the Group-by fields, check the box by the field you want to group by in the bottom-left list view.
- To change the Order-by fields, select a Group-by field (it must be checked) and tap the ">>" button to add it to the Order-by table. To remove a field from the Order-by table, select it and tap the "<<" button. To change the sort order of the Order-by field, the cells of the "Sort Order" column are combo-boxes that may be either ASCENDING or DESCENDING.
- Create a
ServiceFeatureTableusing the URL of a feature service and load the table.
- Get the feature tables field names list with
StatisticDefinitions specifying the field to compute statistics on and the
StatisticsQueryParameterspassing in the list of statistic definitions.
- To have the results grouped by fields, add the field names to the query parameters'
- To have the results ordered by fields, create
OrderBys, specifying the field name and
SortOrder. Pass these
OrderBys to the parameters'
- To execute the query, call
- Get the
StatisticQueryResult. From this, you can get an iterator of
StatisticRecords to loop through and display.
This sample uses a Diabetes, Obesity, and Inactivity by US County feature layer hosted on ArcGIS Online.
correlation, data, fields, filter, group, sort, statistics, table
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/item" android:layout_margin="20dp" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="italic" /> </LinearLayout>