@{constant_name} syntax.
Constants are resolved before other template processing (Mustache and field references) when a query executes or a link renders, making them ideal for values that need to be centrally managed and consistently applied across your model. For example:
- Database schema names that may differ between environments
- Common URL patterns for data links
- Repeated string values that you want to maintain in a single location
- Configuration values that can be dynamically referenced
Syntax
Properties
A map of constant definitions where each key is the constant name. Names must be unique within the model.
Examples
Dynamic schema reference
Use constants to reference schema names that may vary across environments. Define the constants in the model file:Model file
View file
Dynamic links with field references
Create link patterns that include field references. Define the constants in the model file:Model file
Dimensions in a view
Reusable format patterns
Constants are often used with the format parameter on dimensions and measures. Reference a constant with@{constant_name} inside the format string (including inside conditional format branches).
For standard currency and number display, use a named format like
usdcurrency_2 or percent_1 directly. Constants are most valuable for custom Excel-style patterns that appear in several fields.Model file
View file
format page for more detail.