AMD: require(["esri/smartMapping/statistics/uniqueValues"], (uniqueValues) => { /* code goes here */ });
ESM: import uniqueValues from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
Function: esri/smartMapping/statistics/uniqueValues
Since: ArcGIS Maps SDK for JavaScript 4.4

A function that queries for unique values from a field in a Layer.

Known Limitations

  • SceneLayers must have the supportsRenderer and supportsLayerQuery capabilities enabled unless a predefined statistics object is provided to the statistics parameter of the method. To check a SceneLayer's capabilities, use the getFieldInfoUsage() method.
  • You cannot generate unique values using SQL expressions for client-side FeatureLayers in a SceneView.

Method Overview

Name Return Type Summary Function

Returns an object containing an array of unique values queried from a given field (or values returned from an expression) in a Layer along with the total count of features that belong to the given category.


Method Details



Returns an object containing an array of unique values queried from a given field (or values returned from an expression) in a Layer along with the total count of features that belong to the given category.

params Object

See the table below for details of each parameter.


The layer from which to query for unique values.

field String

The name of the numeric or string field from which the unique values will be obtained. This property is ignored if a valueExpression is used.

valueExpression String

An Arcade expression following the specification defined by the Arcade Visualization Profile. Expressions may reference field values using the $feature profile variable and must return a string or a number. This property overrides the field property and therefore is used instead of an input field value.

sqlExpression String

A SQL expression evaluating to a number or string.

sqlWhere String

A SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.

returnAllCodedValues Boolean

Indicates that all domain codes should be returned if the given field has domain values.

view View

A SceneView or MapView instance is required when a valueExpression is specified.

filter FeatureFilter

A feature filter used to filter statistic queries by geometry. This parameter is only used for filtering statistics by geometry. Any attribute filters set on the FeatureFilter.where property are ignored. Currently, only the intersects spatial relationship is supported. This is useful if you already define a feature filter by geometry on your layer and want to calculate statistics for the included features. Since version 4.25.

features Graphic[]
Deprecated since version 4.23. Use useFeaturesInView instead.

A subset of features for which to generate the unique values.

useFeaturesInView Boolean

Only applicable when the input layer is a service-backed FeatureLayer. When true, statistics will be calculated on the client from features visible in the view. If false, statistics will be requested from the service. Since version 4.23.

forBinning Boolean

Indicates whether the generated statistics are for a binning or clustering visualization. If true, then the input field(s) in this method should refer to aggregate fields defined in the featureReduction property of the layer.

signal AbortSignal

Allows for cancelable requests. If canceled, the promise will be rejected with an error named AbortError. See also AbortController.

Type Description
Promise<UniqueValuesResult> Returns a promise that resolves to UniqueValuesResult.
let layer = new FeatureLayer({
  portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }

  layer: layer,
  field: "Candidate"
  // prints each unique value and the count of features containing that value
  let infos = response.uniqueValueInfos;
    console.log("CANDIDATE: ", info.value, " # OF CAMPAIGN STOPS: ", info.count);

Type Definitions


Type Definition

An object that contains the unique values returned from the uniqueValues() query of a layer's field.

uniqueValueInfos Object[]

An array of objects, each containing a unique value/type/category present in the field specified in the uniqueValues() query. See table below for the specification of each object.

value String|Number

A unique value representing a type or category of features in the layer.

count Number

The number of features assigned the given value (or belonging to the given category).

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.