Built-in Functions → queryWithLimit

queryWithLimit() is a query function that queries a column and returns a number of the values that satisfy one or more optional filter conditions with a mandatory maximum number of values to return.

This function is available starting 2024.1.6 and 2024.7.2.

Context

You can use query functions when creating the query expressions of global variables and internal session variables. This function is not supported in In-Query filters.

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

Signature

queryWithLimit(column, limit, filter1, filter2, ...)
ParameterDescription
columnRequired.
The fully qualified name of the column to query its values
limitRequired.
The maximum number of values the function can return
filterOptional.
The conditions to be evaluated against each column value to decide on the 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 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, the type of the returned value is always string.

Example

Query the AMOUNT_SOLD column and return up to 500 values where the CALENDAR_YEAR is 2003.

queryWithLimit(SALES.SALES.AMOUNT_SOLD, 500, SALES.SALES.CALENDAR_YEAR =2003)