Global Variables
Global Variables are user-defined constant values referenced in the Compass query editor by writing ${variable_name}. When a query is executed or a filter is triggered on a Horizon / Atlas dashboard, the backend automatically replaces this placeholder with the saved value.
Access
Click the Settings icon in the left menu → in the dialog that opens select the Global Variables tab.
What It's For
Lets you manage values that repeat across multiple queries (plant name, machine ID, default date range, etc.) from a single place. When the value changes, you do not have to edit each query individually; an update in Global Variables is enough.
UI Field Reference
| Field | Description | Required |
|---|---|---|
| Name | The technical key used inside ${...} in queries. Cannot contain spaces; recommended format: snake_case. |
Yes |
| Value | The actual value substituted in. Can be text, number, or date. | Yes |
${variable} Usage Examples
Global Variables work in all of the following query types:
PostgreSQL
SELECT ts, value
FROM sensor_readings
WHERE plant_code = '${plant_code}'
AND ts >= NOW() - INTERVAL '${lookback_days} days'
ORDER BY ts DESC;
MSSQL (T-SQL)
SELECT TOP 500
RecordTime,
TagValue
FROM dbo.TagHistory
WHERE TagName = '${tag_name}'
AND RecordTime >= DATEADD(HOUR, -${hour_range}, GETDATE());
MySQL
SELECT DATE_FORMAT(ts, '%Y-%m-%d %H:%i') AS period, AVG(value) AS avg_val
FROM measurements
WHERE machine_id = '${machine_id}'
GROUP BY period
ORDER BY period;
MQTT (Topic Filter)
REST API (URL Parameter)
Adding a Variable
- Open Settings → Global Variables tab.
-
Click the + button at the top right.
-
Enter a technical key in Name (e.g.
plant_code). - Enter the actual value in Value (e.g.
IST-01). -
Click Save.
The variable is added to the list and can now be used in all queries.
Editing a Variable
- Hover the row you want to edit in the list.
- Click the pencil (Edit) icon that appears at the end of the row.
- Update the Name or Value.
- Click Save.
Renaming
If you change the Name, the ${old_name} references in all queries that use this variable no longer match. You must update those queries manually.
Deleting a Variable
- Click the trash (Delete) icon at the end of the row you want to delete.
- If a confirmation appears, click Confirm.
No Undo
A deleted variable cannot be recovered. Queries bound to this variable continue to run, but the ${variable_name} placeholder is evaluated as empty or invalid.
Limitations and Notes
| Topic | Description |
|---|---|
| Scope | Variables are per user; variables defined by other users are not visible. |
| Type support | All values are stored as text; you must perform type conversion (e.g. ::integer, CAST) in the query if needed. |
| Case sensitivity | ${plant_code} and ${Plant_Code} are different variables. |
| Spaces | Do not use spaces in Name; use underscore (_) instead. |
| Compass save panel | Inline parameters defined as {{parameter}} while saving a query in Compass are separate from Global Variables — they act as dashboard filters. |



