Built-in Functions → queryDistinct

queryDistinct() is a query function that queries a column and returns its distinct values that satisfy one or more optional filter conditions.

Context

You can use query functions when creating the query expressions of global variables, internal session variables, and In-Query filters.

For more examples and details about referenceable objects and variables, refer to Concepts → Internal Query Expression.

Note

The maximum number of distinct values this function can return is 1000. To have more distinct values returned, use the queryDistinctWithLimit() function.

Signature

queryDistinct(column, filter1, filter2, ...)
ParameterDescription
columnRequired.
The fully qualified name of the column to query its values
filterOptional.
The conditions to be evaluated against each column value to decide on the distinct values to return. A value must satisfy all filter conditions to be considered in the function output.

Returns

A single value or an array of distinct values.

The data type of the returned values depends on the column data type and the function’s usage context. When the function is used in a global variable the type of the returned values is the same as the column’s data type. In the case of a session variable or an In-Query filter, the type of the returned value is always string.

Example

Query the AMOUNT_SOLD column and return distinct values where the CALENDAR_YEAR is 2003.

queryDistinct(SALES.SALES.AMOUNT_SOLD, SALES.SALES.CALENDAR_YEAR =2003)