Skip to main content
Skip table of contents

VARIABLE functions

System variables and scoped variables are used by inserting their values into SQL fragments in the definitions of objects like metrics and filters. The function used to do this is @@VARIABLE, which has the following syntax:

@@VARIABLE(variablename[,"datatype"][,"delimiter"][,"defaultvalue"])

  • The variablename and datatype parameter values are case insensitive. The rest is used as-as.
  • All parameters, except variablename, are optional. However, to define a parameter that comes after another parameter, you must define the preceding parameter value(s).
  • The double quotes (aka string qualifiers) around the parameter values are optional. However, by using double quotes, it allows the delimiter character (, ) to be used in the parameter value.

@@VARIABLE parameters

Parameter

Description

VariableName

The name of the scoped or system variable to look up when resolving its value.

DataType

Determines whether single quotes are added around the replaced value. The default value ignores this setting and never places single quotes around the value. Valid data types are:

  • String: This will add single quotes before and after the value.
  • Number: This will leave the value as is.
  • Date: This will add single quotes before and after the value.
  • Unknown: For system variables, this is determined by the variable name being requested. However, for custom scoped variables, this will leave the value as-is.
  • Exact: This will leave the value as is.

Delimiter

The optional delimiter parameter used to concatenate multiple results into a single string value. The default delimiter is a comma (,). The delimiter is only used when the result set of a scoped variable that is using a dynamic expression returns more than one row. This separator can be any string of characters. When using the delimiter parameter, you must define the datatype parameter before it.

DefaultValue

This is the value that will replace this variable expression when the corresponding variable cannot be found in the hierarchy path or cannot be viewed by the current user when "Apply View permission" is enabled on a scoped variable. By default, an empty string is used when this parameter is not defined. When used, the default value will need to include any surrounding single quotes, since the datatype parameter does not apply to it.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.