Global variables
DranSCADA has global built-in variables that can be used in expressions in the query editor. This topic lists them in alphabetical order and defines them. These variables are useful in queries, dashboard links, panel links, and data links.
Only available in DranSCADA v6.7+. In DranSCADA 7.1, the variable changed from showing the UID of the current dashboard to the name of the current dashboard.
This variable is the name of the current dashboard.
DranSCADA has two built in time range variables: $__from
and $__to
. They are currently always interpolated as epoch milliseconds by default but you can control date formatting.
This special formatting syntax is only available in Grafan a 7.1.2+
Syntax | Example result | Description |
---|---|---|
${__from} |
1594671549254 | Unix millisecond epoch |
${__from:date} |
2020-07-13T20:19:09.254Z | No args, defaults to ISO 8601/RFC 3339 |
${__from:date:iso} |
2020-07-13T20:19:09.254Z | ISO 8601/RFC 3339 |
${__from:date:seconds} |
1594671549 | Unix seconds epoch |
${__from:date:YYYY-MM} |
2020-07 | Any custom date format |
The above syntax works with ${__to}
as well.
You can use this variable in URLs as well.
You can use the $__interval
variable as a parameter to group by time (for MySQL, Postgres, MSSQL).
DranSCADA automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval. It is more efficient to group by 1 day than by 10s when looking at 3 months of data and the graph will look the same and the query will be faster. The $__interval
is calculated using the time range and the width of the graph (the number of pixels).
Approximate Calculation: (from - to) / resolution
For example, when the time range is 1 hour and the graph is full screen, then the interval might be calculated to 2m
- points are grouped in 2 minute intervals. If the time range is 6 months and the graph is full screen, then the interval might be 1d
(1 day) - points are grouped by day.
This variable is the $__interval
variable in milliseconds, not a time interval formatted string. For example, if the $__interval
is 20m
then the $__interval_ms
is 1200000
.
This variable is only available in the Singlestat panel and can be used in the prefix or suffix fields on the Options tab. The variable will be replaced with the series name or alias.
This variable is the ID of the current organization.
${__org.name}
is the name of the current organization.
Only available in DranSCADA v7.1+
${__user.id}
is the ID of the current user.
${__user.login}
is the login handle of the current user.
The $timeFilter
variable returns the currently selected time range as an expression. For example, the time range interval Last 7 days
expression is time > now() - 7d
.
This is used in several places, including:
- Log Analytics queries in the Azure Monitor data source.
- SQL queries in MySQL, Postgres, and MSSQL.
- The
$__timeFilter
variable is used in the MySQL data source.