Skip to content

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

Global Variables screen

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)

factory/${plant_id}/line/+/temperature

REST API (URL Parameter)

/api/v1/sensors?plant=${plant_code}&limit=${page_size}

Adding a Variable

  1. Open SettingsGlobal Variables tab.
  2. Click the + button at the top right.

    New variable button

  3. Enter a technical key in Name (e.g. plant_code).

  4. Enter the actual value in Value (e.g. IST-01).
  5. Click Save.

    New variable form

The variable is added to the list and can now be used in all queries.


Editing a Variable

  1. Hover the row you want to edit in the list.
  2. Click the pencil (Edit) icon that appears at the end of the row.
  3. Update the Name or Value.
  4. 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

  1. Click the trash (Delete) icon at the end of the row you want to delete.
  2. If a confirmation appears, click Confirm.

Variable delete icon

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.

Next Step

My Color PalettesTagsCompass — Create Query