$()
Returns the value of a query parameter.
Syntax
$(EXPR, [DEFAULT_EXPR])
Required Parameter
EXPR
- Expression that returns a query parameter name.
Optional Parameter
DEFAULT_EXPR
- Expression or value that specifies the default return value of the function when
EXPR
isnull
.
Description
A query parameter is a variable that can be called in a query or a procedure. You can declare query parameters using the set or evalc query commands. Using a query parameter is useful when dynamically assigning values to a query and executing it; a query or procedure can reference a value of a query parameter by using the $() function.
Usage
-
Retrieve data recorded in the
YOUR_TABLE
table for the last 7 days from the current time.set from=ago("7d") | set to=str(now()) | table from=$("from") to=$("to") YOUR_TABLE
-
Retrieve data recorded in the
YOUR_TABLE
table for the period specified by the query parameters_from
and_to
. If the query parameters have no value (null
), retrieve data for the last 1 day from the current time.table from=$("_from", ago("1d")) to=$("_to", now()) YOUR_TABLE