Formula Editor
The Formula Editor is a text editor that opens when clicking the arrow next to input fields or selecting Configure from the dropdown list.
In formulas, you can use ClickHouse functions. For a full reference, see the official ClickHouse documentation.
Formula Editor Tabs
Tables and Columns
The Tables and Columns tab displays tables added to the workspace. To show a table, click Show table and select the required one from the dropdown list.
You can locate the desired table using the search field.
After selecting a table, its columns are listed. Multiple tables and their columns can be displayed simultaneously. To expand a table’s column list, click the arrow icon to the left of its name.
To insert a column into the formula, click it. To find a specific column, first select the table, then type the column name into the search field.
When you click a column, its data type is displayed above its name.
Autocomplete for table and column names (from the right-hand panel) is available while writing formulas. To trigger it, start typing a name and press Ctrl+Space. If several matches exist, they appear as a list below the formula; if only one match exists, it is inserted automatically.
- If a table or column name contains a double hyphen
--, everything following--in the formula line will be treated as a comment. - If two or more workspaces contain tables with identical names, the table state opened in the Formula Editor of the first workspace persists in editors of other workspaces until the browser is closed.
Once the formula is ready, click Save.
Variables
This tab is hidden if the dashboard contains no custom variables.
The Variables tab contains system variables, dashboard variables, and incoming input values. To expand a variable category, click the arrow icon to the left of its name.
Use the search field to find a specific variable.
To add a variable to the formula, click it—or use the ${Variable Name} syntax manually.
- The
${Variable Name}syntax is also used for referencing system variables and incoming input values. - Variables can be referenced in any text field where the Formula Editor is available (e.g., widget, dimension, or measure names; format, formatting, etc.).
If a variable or indicator name contains any of the following characters— }, ., [, ], \—they must be escaped with a backslash (\).
System Variables
System variables provide real-time values of specific system parameters.
To access a system variable, the user must have the Platform module privilege (User Access) with the R operation.
Available system variables:
- currentEmployeeId
- currentEmployeeEmail
The currentEmployeeId and currentEmployeeEmail variables can pass user context to scripts while running a script from dashboard. They can also be used to filter widget data so that each user sees only their own records.
currentEmployeeId returns the current dashboard user’s unique identifier. Using it avoids querying the employee table to resolve an ID from a login.
currentEmployeeEmail returns the current dashboard user’s email address.
If a user-created variable has the same name as a system variable, the system variable’s value is overridden. To restore the original system value, rename the custom variable.
Dimensions
A group appears in this tab only if it contains at least one dimension.
The Dimensions tab lists global workspace indicator groups and dashboard-specific dimensions. The Common group (global indicators) always appears first. To expand a group’s dimension list, click the arrow icon to the left of the group name.
To insert a dimension into the formula, click its name. The syntax is: #{Group Name}.{Dimension Name}.
Measures
A group appears in this tab only if it contains at least one measure.
The Measures tab lists global workspace indicator groups and dashboard-specific measures. The Common group (global indicators) always appears first. To expand a group’s measure list, click the arrow icon to the left of the group name.
To insert a measure into the formula, use the syntax: #{Group Name}.{Measure Name}.
Colors
The Colors tab appears only when configuring a color (e.g., for display rules).
Additional Features
Find and Replace
The editor includes built-in Find and Find & Replace tools. To open the search field, right-click and select Find.
To access replace functionality, select Find and Replace, then use the arrows next to the Replace field. → (one arrow) means replacing the currently selected match; →→ (two arrows) means replacing all matches.
Keyboard Shortcuts
The Formula Editor supports the following shortcuts:
- Ctrl+A — select all
- Ctrl+X — cut
- Ctrl+C — copy
- Ctrl+V — paste
- Ctrl+Z — undo
- Ctrl+Shift+Z — redo
- Tab — indent right
- Shift+Tab — indent left
- Ctrl+Shift+X — uppercase
- Ctrl+Shift+Y — lowercase
- Ctrl+/ — toggle single-line comment
- Ctrl+Shift+/ — toggle multi-line comment
- Ctrl+D — duplicate line(s)
- Ctrl+Shift+D — delete current line
- Ctrl+F — find
- Ctrl+H — find and replace
- Ctrl+Shift+F — auto-format
- Ctrl+Space — autocomplete
- Ctrl+S — save and close editor
Formula Usage Notes
Keep the following nuances in mind when working with formulas:
- When using the
multiIffunction with columns from different tables as arguments, data may render incorrectly—e.g., when dynamically switching measures on a chart
We recommend using measure display conditions instead. Configure a separate condition for each measure in the widget. This ensures accurate calculations without forcing heterogeneous measures into a single data format - Do not wrap table or column names in backticks—this may cause evaluation errors. Use double quotes (
"). String literals must use single quotes (') - In Operavix, you can use variables as dynamic column names in formulas (e.g., via Column List). Since such columns may have varying data types, runtime errors may occur. To avoid this:
- Ensure all candidate columns share the same data type
- Dynamically bind the indicator’s
dbDataTypeto a variable in YAML, as shown below:
dimensionsAndMeasures:
- name: Formula
type: DIMENSION
value:
mode: FORMULA
formula: '!${Input value}."priority"'
dbDataType: '{Input value 1}'
- Prefixing a variable with an exclamation mark (
!) automatically wraps its value in double quotes. Usage example:- In the dashboard, create and configure a Column List variable.
- Add a Table widget to the dashboard. Set the dimension formula to
"Table_Name".!${Column List}. - Add a Parameter widget and assign the Column List variable to it.
- Publish the dashboard. Now, changing the Column List variable’s value via the Parameter widget dynamically updates the referenced column in the table’s dimension.
Was the article helpful?